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!
if it is the equal width that you want, you can go for linearLayout with children of equal weight. check out the following 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
seems better, because the number of columns won't change. With GridView
you have to add adapters and stuff.
You can make a good combination of TableLayout with TableRow, and make rows and columns as you want, very easy.
This is an example with 2x2 grid with 4 buttons (put insidea a LinearLayout for example):
<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>
The best is to use a gridview. Try someothing like this :
<GridView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="7" />
/>
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnWidth="90dp"
android:numColumns="7"
android:stretchMode="columnWidth"
android:gravity="center"
/>
try this..
© 2022 - 2024 — McMap. All rights reserved.