簡體   English   中英

無法擺脫按鈕上的底部填充

[英]Can't get rid of bottom padding on button

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

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

在資源編輯器中,我可以單擊按鈕,然后在那里看到按鈕底邊下方的填充。 這似乎阻止我在父RelativeLayout中垂直居中按鈕。

在此輸入圖像描述

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

謝謝

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

我建議不要試圖補償,因為這些圖形資源可能會在沒有通知的情況下發生變化。 你最好建立自己的9補丁或編輯現有補丁來刪除填充。

設置android:layout_marginBottom =“ - 5dp”為按鈕很好地為我工作。

我很晚才回答這個問題,但是如果有人遇到類似的用例( 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" />

Hmn真奇怪。 從來沒有注意到。 可能是因為你通常需要在你的按鈕周圍留一點空間。

還嘗試了margin / padding = 0dp並且確實不起作用。

你可以設置android:layout_marginBottom =“ - 10dp”但是:)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM