How to dynamic adjust the width of columns in Table layout
- by michael
Hi,
I create a TableLayout which has 3 equally-wide columns (I put 'stretchColumns="*" in my TableLayout which has 3 TextViews). See below:
But my questions is why I set one of the TextView to 'visibility' to Gone in my java code, the TableLayout does not re-size to 2 qually-wide columns which fit the whole screen. I have even call 'tableLayout.requestLayout()' after i set the visibility to Gone.'
How can I achieve what I want?
Thank you.
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="@+id/textpanel"
android:stretchColumns="*">
<TableRow android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/text2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/text3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>