Reputation: 734
Why does not my second TableView
appear?
I want to create scroll-able TableView
but I don't want to scroll my first row (it is a header) , so I thought to have 2 table views in vertical layout and the second table is in ScrollView
, but my code does not work....
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableLayout
android:id="@+id/main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:shrinkColumns="0"
android:stretchColumns="*" >
<TableRow
android:id="@+id/ww"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff"
android:padding="5dip" >
<TextView
android:id="@+id/w"
android:layout_marginLeft="2dp"
android:background="#000000"
android:text="#"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/aaa"
android:layout_marginLeft="5dp"
android:background="#000000"
android:text="ID"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/sss"
android:layout_marginLeft="5dp"
android:background="#000000"
android:text="Initials"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/ddd"
android:layout_marginLeft="5dp"
android:background="#000000"
android:text="Last Session"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
</TableLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableLayout
android:id="@+id/patientsTable"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:shrinkColumns="0"
android:stretchColumns="*" >
<TableRow
android:id="@+id/pp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff"
android:padding="5dip" >
<TextView
android:id="@+id/uu"
android:layout_marginLeft="2dp"
android:background="#000000"
android:text="#"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/uuu"
android:layout_marginLeft="5dp"
android:background="#000000"
android:text="ID"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/uuuu"
android:layout_marginLeft="5dp"
android:background="#000000"
android:text="Initials"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/yyy"
android:layout_marginLeft="5dp"
android:background="#000000"
android:text="Last Session"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
</TableLayout>
</ScrollView>
</LinearLayout>
Upvotes: 0
Views: 48
Reputation: 9569
Just play with weights.
<TableLayout
android:id="@+id/main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:shrinkColumns="0"
android:stretchColumns="*" >
<TableRow
android:id="@+id/ww"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff"
android:padding="5dip" >
<TextView
android:id="@+id/w"
android:layout_marginLeft="2dp"
android:background="#000000"
android:text="#"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/aaa"
android:layout_marginLeft="5dp"
android:background="#000000"
android:text="ID"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/sss"
android:layout_marginLeft="5dp"
android:background="#000000"
android:text="Initials"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/ddd"
android:layout_marginLeft="5dp"
android:background="#000000"
android:text="Last Session"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
</TableLayout>
<ScrollView
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="fill_parent" >
<TableLayout
android:id="@+id/patientsTable"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:shrinkColumns="0"
android:stretchColumns="*" >
<TableRow
android:id="@+id/pp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff"
android:padding="5dip" >
<TextView
android:id="@+id/uu"
android:layout_marginLeft="2dp"
android:background="#000000"
android:text="#"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/uuu"
android:layout_marginLeft="5dp"
android:background="#000000"
android:text="ID"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/uuuu"
android:layout_marginLeft="5dp"
android:background="#000000"
android:text="Initials"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/yyy"
android:layout_marginLeft="5dp"
android:background="#000000"
android:text="Last Session"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
</TableLayout>
</ScrollView>
Upvotes: 1
Reputation: 11978
I think it's because you set the first Table's height to fill_parent
. Try to change it to wrap_content
. If this does not work, you can also change your parent container as follows:
<RelativeLayout
... >
<TableLayout
android:id="@+id/first_table"
android:layout_alignParentTop="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
... >
</TableLayout>
<ScrollView
android:layout_below="@id/first_table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
... >
</ScrollView>
</RelativeLayout>
Upvotes: 1