2011-03-06 44 views
5

我有一個按鈕。它似乎有底部填充我無法擺脫的:無法擺脫按鈕上的底部填充

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Foo"/> 

在資源編輯器,我可以按一下按鈕,你可以看到該按鈕出現的底部邊緣下方的填充。這似乎阻止我正確地在父親RelativeLayout中居中對齊按鈕。

enter image description here

我試圖設置填充= 0dip和layout_margin = 0dip,沒有效果。該底部填充持續存在。

謝謝

回答

5

填充位於按鈕本身的9個補丁中。

我建議不要試圖補償,因爲這些圖形資源可能會改變,恕不另行通知。你最好是building your own 9-patch或編輯現有的刪除填充。

+0

唉來。謝謝。 – user291701 2011-03-06 23:50:15

0

Hmn真的很奇怪。從未注意到。可能是因爲你在想要你的按鈕周圍有一點空間。

也嘗試了margin/padding = 0dp,但實際上並沒有工作。

但是,您可以設置android:layout_marginBottom =「 - 10dp」:)。

3

設置android:layout_marginBottom =「 - 5dp」這個按鈕對我很好用。

2

我來不及回答,但認爲共享,如果有人遇到類似的用例(Removing all the inner and outer padding in Button

<Button 
android:id="@+id/textView1" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_marginBottom="-5dp" 
android:layout_marginLeft="-5dp" 
android:layout_marginRight="-5dp" 
android:layout_marginTop="-5dp" 
android:minHeight="-2dp" 
android:minWidth="-2dp" 
android:text="TextView" 
android:textSize="12sp" />