Monday, September 10, 2012

[android-developers] TableLayout border issue

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?
Image of the problem: http://i.stack.imgur.com/E8gu5.png
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>

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment