5

http://img683.imageshack.us/img683/645/weatherscreenmockupoutl.png

I am asking myself whats the best way to code this layout. Basicly i just need to know how to get seven columns with an equal width.

Thanks in advance!

4

5 に答える 5

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>
于 2011-10-25T07:47:14.180 に答える
3

TableLayout列の数は変わらないので、より良いようです。GridViewアダプターなどを追加する必要があります。

于 2011-10-25T07:43:48.897 に答える
2

TableLayout と TableRow を適切に組み合わせて、必要に応じて行と列を非常に簡単に作成できます。

これは、4 つのボタンを持つ 2x2 グリッドの例です (たとえば、LinearLayout 内に配置します)。

<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>
于 2012-04-03T11:12:06.877 に答える
0

最善の方法は、グリッドビューを使用することです。次のようなことを試してください:

<GridView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:numColumns="7" />
于 2012-12-18T08:02:28.420 に答える