2016-06-08 89 views
0

我剛剛創建了一個LinearLayoutWeightSum並將Button放在它裏面。但我的Button正在佔用空間沒有我申請任何風格或財產不工作,因爲我的預期。爲什麼按鈕被放在兩個按鈕之間的額外空間android

XML代碼:

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_gravity="center_horizontal" 
     android:background="#FFFFFF" 
     android:orientation="horizontal"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:orientation="horizontal"> 

      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="#e6e6e6" 
       android:orientation="vertical" 
       android:weightSum="13.0"> 

       <Button 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="1.0" 
        android:gravity="center" 
        android:text="T" 
        android:textColor="#000000"/> 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="0dp" 
        android:layout_weight="1.0" 
        android:gravity="center" 
        android:text="A" 
        android:textColor="#000000"/> 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="0dp" 
        android:layout_weight="1.0" 
        android:gravity="center" 
        android:text="J" 
        android:textColor="#000000"/> 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="0dp" 
        android:layout_weight="1.0" 
        android:gravity="center" 
        android:text="R" 
        android:textColor="#000000"/> 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="0dp" 
        android:layout_weight="1.0" 
        android:gravity="center" 
        android:text="D" 
        android:textColor="#000000"/> 
       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="0dp" 
        android:layout_weight="1.0" 
        android:gravity="center" 
        android:text="K" 
        android:textColor="#000000"/> 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="0dp" 
        android:layout_weight="1.0" 
        android:gravity="center" 
        android:text="I" 
        android:textColor="#000000"/> 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="0dp" 
        android:layout_weight="1.0" 
        android:gravity="center" 
        android:text="E" 
        android:textColor="#000000"/> 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="0dp" 
        android:layout_weight="1.0" 
        android:gravity="center" 
        android:text="F" 
        android:textColor="#000000"/> 
       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="0dp" 
        android:layout_weight="1.0" 
        android:gravity="center" 
        android:text="G" 
        android:textColor="#000000"/> 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="0dp" 
        android:layout_weight="1.0" 
        android:gravity="center" 
        android:text="H" 
        android:textColor="#000000"/> 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="0dp" 
        android:layout_weight="1.0" 
        android:gravity="center" 
        android:text="L" 
        android:textColor="#000000"/> 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="0dp" 
        android:layout_weight="1.0" 
        android:gravity="center" 
        android:text="C" 
        android:textColor="#000000"/> 

      </LinearLayout> 
     </LinearLayout> 

    </LinearLayout> 

輸出截圖:

enter image description here

+1

嘗試改變按鈕的背景下,以特定的顏色,我猜測空間會消失。 'android:background =「#f00」'所有按鈕。 –

+0

@SouravKanta感謝它工作正常。 – Ironman

回答

0

這是因爲默認背景繪製。

嘗試將自定義繪圖設置爲按鈕。例如android:background="#9e9e9e"

您還可以從here獲得自定義繪圖。所有按鈕的

0

設定背景爲空

以下行添加到所有按鈕

的android:背景=「@空」

相關問題