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!
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!
必要な幅が等しい場合は、同じ重みの子を持つ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>
TableLayout
列の数は変わらないので、より良いようです。GridView
アダプターなどを追加する必要があります。
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>
最善の方法は、グリッドビューを使用することです。次のようなことを試してください:
<GridView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="7" />