2016-06-08 92 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:背景=“@空”

相关问题