Reputation: 12479
I have a table that has a border around each of the table rows. I get a problem with the border part when text in one column goes onto a second line, while the text in the other column doesn't. That causes the row that doesn't have the text wrapped onto a second line to be be shorter and a black background on the second line. How can I get that row to be the same height as the other row?
My code is:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#013567" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shrinkColumns="*"
android:stretchColumns="*" >
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000" >
<TextView
android:id="@+id/textView2"
android:layout_margin="2dip"
android:background="#013567"
android:gravity="center"
android:text="long text abc 123 ong tex ong tex"
android:textColor="#fff" >
</TextView>
<TextView
android:id="@+id/textView3"
android:layout_margin="2dip"
android:background="#013567"
android:gravity="center"
android:text="short text"
android:textColor="#fff" >
</TextView>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000" >
<TextView
android:id="@+id/textView2"
android:layout_margin="2dip"
android:background="#013567"
android:gravity="center"
android:text="short text"
android:textColor="#fff" >
</TextView>
<TextView
android:id="@+id/textView3"
android:layout_margin="2dip"
android:background="#013567"
android:gravity="center"
android:text="long text abc 123 ong tex ong tex"
android:textColor="#fff" >
</TextView>
</TableRow>
</TableLayout>
</ScrollView>
Example:
Upvotes: 0
Views: 1307
Reputation: 3009
There is a couple of ways to fix this,
add a FrameLayout around each text with android:layout_height="match_parent"
.
or
change your stying to be applied to the table, as e.g.
How to style a tablelayout in android
setting the Table background to be the blue and borders to be black.
Upvotes: 0
Reputation: 104
add following properties to your TextView
, not your TableRow
:
android:layout_height="match_parent"
or
android:layout_height="fill_parent"
(deprecated)
Upvotes: 1
Reputation: 104
add new line to the en of 'short text'
programmatically:
\n
xml:
Upvotes: 0
Reputation: 68187
Try setting the following to your TableRow
:
android:layout_height="fill_parent"
Upvotes: 0