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 に答える