2016-03-23 104 views
0

有沒有一種方法可以根據圖像尺寸指定圖像的邊距尺寸?基於圖像大小一半的Android保證金大小?

假設圖片尺寸是50dp,我想指定50%的邊距來獲得25dp的邊距設置?

但是,您可以指定與容器視圖相關的百分比值,而不是相關的實際視圖。

這是可能的通過XML?

<ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal" 
      android:layout_marginTop="-50dp" 
      android:src="@drawable/tool_tip" /> 
+0

AFAIK這個Percent Support Librarythis後無法通過XML。但你可以手動完成。 – Sipty

回答

0

你可能想看看在G +