0

基本上我想获得一个行为类似于 Java GridLayout 的布局。

我尝试了 LinearLayout 和 TableRow,但元素总是一个接一个地添加。

实现这一目标的最佳方法是什么(使用 xml 方法)?

4

2 回答 2

2

据此,可以将 GridLayout 与支持库一起使用

一个新的库项目将 GridLayout 支持添加回 API 级别 7 及更高级别

于 2012-04-23T09:39:12.203 回答
0

解决了它:

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


    <Button
        android:id="@+id/button1"
        style="@style/ButtonStyle"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:background="@drawable/main_buttons"
        android:text="@string/sGet" 
        android:layout_weight="1" />

    <Button
        android:id="@+id/button2"
        style="@style/ButtonStyle"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:background="@drawable/main_buttons"
        android:text="@string/sStop"
        android:layout_weight="1" />

    <Button
        android:id="@+id/button3"
        style="@style/ButtonStyle"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:background="@drawable/main_buttons"
        android:text="@string/sSettings"
        android:layout_weight="1" />

    <Button
        android:id="@+id/button4"
        style="@style/ButtonStyle"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:background="@drawable/main_buttons"
        android:text="@string/sExit"
        android:layout_weight="1" /> 

</LinearLayout>
于 2012-04-23T09:55:29.390 回答