TableLayout has a TextView
and EditText
on each row. When EditText
has a multiple row, TableRow
wraps it but when TextEdit
, it doesn't..
Simplyfied layout:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:shrinkColumns="*" >
<TableRow>
<TextView
android:id="@+id/textView1"
android:text="Lorem ipsum dolor sit amet, consectetur" />
<EditText
android:id="@+id/textView2"
android:text="Foo" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/textView3"
android:text="Foo" />
<EditText
android:id="@+id/textView4"
android:text="Lorem ipsum dolor sit amet, consectetur" />
</TableRow>
</TableLayout>
Renders:
But when both controls are TextEdit
, it renders correctly.
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:shrinkColumns="*" >
<TableRow>
<TextView
android:id="@+id/textView1"
android:text="Lorem ipsum dolor sit amet, consectetur" />
<TextView
android:id="@+id/textView2"
android:text="Foo" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/textView3"
android:text="Foo" />
<TextView
android:id="@+id/textView4"
android:text="Lorem ipsum dolor sit amet, consectetur" />
</TableRow>
</TableLayout>
Renders as:
What should i do for Android to render first layout correctly?
Ps: I have already tried to add android:layout_width="fill_parent"
,android:layout_height="wrap_content
" attributes to TableRow
, TextView
, EditText
controls, nothing has changed.
I had the same problem and what solved everything was setting a weight to the textviews i wanted to word wrap.
My two cents...