TableLayout formatting loss after device rotation
Posted
by roundhill
on Stack Overflow
See other posts from Stack Overflow
or by roundhill
Published on 2010-06-14T18:46:24Z
Indexed on
2010/06/14
18:52 UTC
Read the original article
Hit count: 213
I'm seeing a strange issue with a TableLayout after the device is rotated from either orientation. If you load the view in either portrait or landscape mode, the table loads fine. But once you rotate the device, the columns collapse to just fit their width. I would expect that after rotation, the columns would still stretch to fit the width of the screen. Any ideas on what can be done to resolve this? Screenies and layout code below.
Before Rotation:
After Rotation:
Table Layout:
<TableLayout android:id="@+id/dataTable"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_below="@id/chart"
android:stretchColumns="*"
android:shrinkColumns="*"
android:padding="6dip"
>
</TableLayout>
Table Row:
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/col1"
android:layout_marginRight="2dip"
android:textColorLink="#FF21759b"
android:text="Column 1"
android:padding="4dip"
android:textColor="#FF464646"/>
<TextView android:id="@+id/col2" android:text="Column 2"
android:textColor="#FF464646"
android:padding="4dip"/>
</TableRow>
Thanks!
© Stack Overflow or respective owner