How to dynamic adjust the width of columns in Table layout
Posted
by michael
on Stack Overflow
See other posts from Stack Overflow
or by michael
Published on 2010-05-11T00:15:22Z
Indexed on
2010/05/11
2:44 UTC
Read the original article
Hit count: 493
android
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>
© Stack Overflow or respective owner