答えて

4

希望の幅であれば、等しい体重の子供を持つlinearLayoutに行くことができます。次のXMLをチェックしてください。

<LinearLayout 
    layout:orientation="horizontal" 
> 
    <LinearLayout 
     android:id = "@+id/firstcolumn" 
     android:layout_weight="1" 
     android:orientation="vertical" 
     android:layout_width="0dp" 
    > 
    // do the same for your rest of the six children 

</LinearLayout> 
3

TableLayoutは、列の数が変更されないため、より良いようです。 GridViewでは、アダプターやものを追加する必要があります。

2

TableRayoutをTableRowと組み合わせて、簡単に行と列を作成できます。

<TableLayout 
    android:id="@+id/tableLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" > 

    <TableRow 
     android:id="@+id/tableRow3" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <Button 
      android:id="@+id/button1" 
      android:layout_weight="1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 

     <Button 
      android:id="@+id/button2" 
      android:layout_weight="1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 
    </TableRow> 

    <TableRow 
     android:id="@+id/tableRow4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 

     <Button 
      android:id="@+id/button3" 
      android:layout_weight="1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 

     <Button 
      android:id="@+id/button4" 
      android:layout_weight="1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 
    </TableRow> 
</TableLayout> 
0

最高のGridViewのを使用することです:

これは4つのボタン(例えばのLinearLayout insidea置く)と2x2のグリッドとの一例です。このようsomeothing試してみてください:

<GridView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:numColumns="7" /> 
+0

明白な解決策のように思えるが、静的コンテンツのため、私はまだのLinearLayoutで行くと思います。 GridViewには、アダプタを実装する必要があります。 – timoschloesser

0
/> 
<GridView 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:columnWidth="90dp" 
android:numColumns="7" 
android:stretchMode="columnWidth" 
android:gravity="center" 
/> 

この..

関連する問題