0
我刚刚创建了一个LinearLayout
与WeightSum
并将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>
输出截图:
尝试改变按钮的背景下,以特定的颜色,我猜测空间会消失。 'android:background =“#f00”'所有按钮。 –
@SouravKanta感谢它工作正常。 – Ironman