2011-01-13 41 views
5

我有一個簡單的佈局:我的按鈕周圍的額外空間來自哪裏?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:orientation="vertical" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent"> 
    <LinearLayout android:orientation="horizontal" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:padding="5dp" 
        android:id="@+id/acquiring_signal_layout"> 
     <ProgressBar android:id="@+id/ProgressBar01" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"/> 
     <TextView android:id="@+id/acquiring_signal_label" 
        android:text="@string/acquiring_signal" 
        android:layout_width="fill_parent" 
        android:textAppearance="?android:attr/textAppearanceLarge" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical" 
        android:paddingLeft="5dp"/> 
    </LinearLayout> 
    <com.google.android.maps.MapView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/mapview" 
     android:clickable="true" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:apiKey="..." 
     android:layout_weight="1"/> 
    <Button 
     android:text="@string/send_button" 
     android:id="@+id/SendButton" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 
    </Button> 
</LinearLayout> 

它工作正常,它呈現時除外,在底部的按鈕,似乎有幾個(約5,我猜)的周圍的黑框邊緣/空間像素。設置按鈕的邊距似乎沒有任何影響。這是怎麼回事?

回答

6

這是用於按鈕背景的可繪圖。在可繪製按鈕中有幾個像素是透明的。如果你將drawable設置爲你自己的,你會注意到沒有「空白空間」。

+0

從文檔中,可繪製的{Left,Right等}屬性在按鈕內部繪製項目*,而不是在其外圍。例如,按鈕內的圖標可以用drawableLeft顯示。我正在談論窗口小部件之外的黑色空間*,但仍然由按鈕呈現。 – 2011-01-13 16:20:16

0

您是否嘗試過爲按鈕設置負邊距?