2013-10-02 32 views
0

時,這是很難用語言來解釋,所以我會告訴你的圖像來說明問題的ImageButton填充添加比例

image imagebutton padding added scaling scaleType

正如你看到的,paddingTop和paddingBottom來已縮放的ImageView後添加作爲「centerInside」。

我不喜歡它,因爲這樣我就失去了設計的控制。

我知道我可以把android:marginTop =「 - 5dp」,但它不是一個好的解決方案,因爲它可能不適用於每個設備。

這裏是ImageButton的

 <ImageButton 
      android:id="@+id/login_button_twitter" 
      android:src="@drawable/login_twitter_button_es" 
      android:layout_above="@+id/login_button_account" 
      android:background="@null" 
      android:text="@string/access_twitter" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:scaleType="centerInside" 
      /> 

做的,你知道,如果我已經設置了layout_height和layout_width作爲WRAP_CONTENT它爲什麼增加這個空間的代碼?

非常感謝!

回答

0

這是由於圖像對於邊界很大而引起的。

嘗試添加下面一行到你的ImageButton

android:adjustViewBounds="true" 

這將導致搜索的邊界來包裝其內容。