I want to create a layout like this picture:
I tried to create something like this:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:stretchColumns="*" >
<TableRow
android:id="@+id/sth"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView android:text="hello" />
<TextView android:text="hello2" />
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:stretchColumns="*" >
<TableRow
android:id="@+id/sth1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView android:text="hello3" />
<TextView android:text="hello4" />
<TextView android:text="hello5" />
</TableRow>
<TableRow
android:id="@+id/sth2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView android:text="test1" />
<TextView android:text="test2" />
<TextView android:text="test3" />
</TableRow>
</TableLayout>
</TableRow>
</TableLayout>
But the result is this one:
As you can see, three TextViews are disappeared and I have no idea about that. What should I do?
I changed code to this:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:stretchColumns="*" >
<TableRow
android:id="@+id/sth"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
>
<TextView android:text="hello" />
<TextView android:text="hello2" />
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:stretchColumns="*" >
<TableRow
android:id="@+id/sth1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<TextView android:text="hello3" />
<TextView android:text="hello4" />
<TextView android:text="hello5" />
</TableRow>
<TableRow
android:id="@+id/sth2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<TextView android:text="test1" />
<TextView android:text="test2" />
<TextView android:text="test3" />
</TableRow>
<TableRow
android:id="@+id/sth3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<TextView android:text="test4" />
<TextView android:text="test5" />
<TextView android:text="test6" />
</TableRow>
</TableLayout>
</TableRow>
</TableLayout>
The thing is, I add android:layout_weight="1"
and it works! Thanks to Darkie for advice.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments