Struggling with Android Layout
I am struggling in how to create this layout [ImageShack Link] for my android application.
I tried nesting several things into each other but I kept getting errors and I finally have some code which does nothing like I want it to. I hope I get an idea on what layouts I should use and how I nest them together.
Here is my XML code:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:id="@+id/TableLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<TableRow android:id="@+id/TableRow01" andro开发者_如何学编程id:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:text="94.6" android:id="@+id/id_number" android:layout_width="fill_parent" android:layout_height="fill_parent"></TextView>
</TableRow>
<TableRow android:id="@+id/TableRow02" android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:text="KG" android:id="@+id/id_unit" android:layout_width="fill_parent" android:layout_height="fill_parent"></TextView>
</TableRow>
<TableRow android:id="@+id/TableRow03" android:layout_width="fill_parent" android:layout_height="fill_parent">
<Button android:text="@+id/Add" android:id="@+id/add_button" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
<Button android:text="@+id/View" android:id="@+id/view_button" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
</TableRow>
</TableLayout>
I'd go with RelativeLayout
for the whole thing that includes another RelativeLayout
for the upper part of the screen (Big Word here and the rest)
I'd also go with RelativeLayout, maybe, if you're new on android dev and want to test your layouts on a wysiwyg ide, you can use droiddraw...
pseudo xml:
<Vertical LinearLayout>
<BigWord TextView align="center" />
<Horizontal LinearLayout>
<TextView 1 />
<TextView 2 />
<Horizontal LinearLayout>
</Vertical LinearLayout>
<TableLayout>
<TableRow>
<TextView NothingHere />
<TextView TextHere />
</TableRow>
<TableRow>
<Button 1 />
<Button 2 />
</TableRow>
</TableLayout>
I think, You can use TableLayout under ViewFlipper.. and use TableRow for all the texts & buttons, also use the attribute 'stretchColumns' in table layout, that will help you to add the number of columns you want..
and also you can take help from this site- http://www.knowledge-transfers.com/it/android-layout-tutorial/
this helps me a lot..
You should try using a RelativeLayout
instead of a TableLayout
. Check out this tutorial
精彩评论