我正在尝试在一种布局的3行中设置9个按钮。但是,由于某些按钮比其他按钮包含更多的文本,因此这些按钮不适合使用。现在看起来像这样:
我试图将每行放在中LinearLayout
,weightSum = 3
但这些行消失了。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#32c6a6"
android:weightSum="3">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:id="@+id/kontaktfrag">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="13 egenskaber"
android:id="@+id/button"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="left|top"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profeternes egenskaber"
android:id="@+id/button10"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="center_horizontal|top"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bøntider"
android:id="@+id/button2"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="right|top"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wudu"
android:id="@+id/button3"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="left|center_vertical"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wudu's betingelser"
android:id="@+id/button4"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="center"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wudu's afbrydelser"
android:id="@+id/button5"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="right|center_vertical"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bønnens søjler"
android:id="@+id/button6"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="left|bottom"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bønnens betingelser"
android:id="@+id/button7"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="center_horizontal|bottom"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bønnens afbrydelser"
android:id="@+id/button8"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="right|bottom"/>
</FrameLayout>
</LinearLayout >
也曾尝试使用此解决方案,但并没有解决我的问题。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#32c6a6"
android:weightSum="3">
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linRow1"
android:layout_weight="1"
android:weightSum="3">
<Button
android:text="13 egenskaber"
android:id="@+id/button"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:text="Profeternes egenskaber"
android:id="@+id/button10"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:text="Bøntider"
android:id="@+id/button2"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linRow2"
android:layout_weight="1"
android:weightSum="3">
<Button
style="?android:attr/buttonStyleSmall"
android:text="Wudu"
android:id="@+id/button3"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:text="Wudu's betingelser"
android:id="@+id/button4"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
style="?android:attr/buttonStyleSmall"
android:text="Wudu's afbrydelser"
android:id="@+id/button5"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linRow3"
android:layout_weight="1"
android:weightSum="3">
<Button
android:text="Bønnens søjler"
android:id="@+id/button6"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:text="Bønnens betingelser"
android:id="@+id/button7"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:text="Bønnens afbrydelser"
android:id="@+id/button8"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
检查一下
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句