2011-03-06 52 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" />