tablelayout - Android table layout formatting problems -
i can not tablelayout fit inside screen when text cell large
, despite text wraps inside cell
.
this tablelayout. simple two-rows, two-columns table. left column cells multiline
. if text of 1 of these cell large enought break in 2 lines, column stretched fill entire screen , right columns pushed out of screen.
why? how can force full table stay inside screen? hint welcomed.
my tablelayout following:
<tablelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mytablelayout" android:layout_width="fill_parent" android:layout_height="fill_parent" > <tablerow> <textview android:text="account 4 large name see if breaks on 2 or more lines" android:singleline="false" android:layout_width="wrap_content" android:layout_height="wrap_content" > </textview> <textview android:text="$400.00" android:gravity="right" android:layout_width="wrap_content" android:layout_height="wrap_content" > </textview> </tablerow> <tablerow> <textview android:text="account 5" android:singleline="false" android:layout_width="wrap_content" android:layout_height="wrap_content" > </textview> <textview android:text="$400.00" android:gravity="right" android:layout_width="wrap_content" android:layout_height="wrap_content" > </textview> </tablerow> </tablelayout>
the code display layout basic:
public class accountbrowsertest extends activity { public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); this.setcontentview(r.layout.accountbrowser_test); } }
add android:stretchcolumns
, android:shrinkcolumns
tablelayout
element:
<tablelayout android:layout_width="match_parent" android:layout_height="wrap_content" android:stretchcolumns="1" android:shrinkcolumns="1">
the 1
values columns want changes occur. can specify more 1 value this:
android:stretchcolumns="0,1"
or if want changes happen columns this:
android:stretchcolumns="*"
please here detailed information: http://android-pro.blogspot.com/2010/02/table-layout.html
Comments
Post a Comment