Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android TableRow RelativeLayout Issue

I have the following

<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/admin_row"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:gravity="center_horizontal">
    <RelativeLayout android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:orientation="horizontal"
                    android:background="@color/silver">

I dynamically populate the table but with the relative layout colored silver it only spans about 3/4 of the table row. If I put a LinearLayout with horizontal orientation it spans completely but if I change it to vertical the same problem occurs. I need a relative layout in the table row because I need to something like this:

Value
Detail MoreDetail.

Any ideas on getting the relative layout to span the table row?

like image 844
phogel Avatar asked Jan 19 '10 16:01

phogel


2 Answers

Try setting android:stretchColumns="0" or else android:stretchColumns="*" on your TableLayout tag.

like image 85
Eric Burke Avatar answered Sep 20 '22 11:09

Eric Burke


So I had temporarily moved on from this issue but it came up again. To reiterate, the problem I was seeing was that a relative layout within a table row would not span the entire row no matter what I set it's width and height to. I have found a solution that forces any layout to span the table row entirely (horizontally):

<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/detail_row"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content">
    <RelativeLayout android:layout_height="fill_parent"
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:orientation="horizontal">

Note this seems to be in direct contradiction to what the table row java docs state:

The children of a TableRow do not need to specify the layout_width and layout_height attributes in the XML file. TableRow always enforces those values to be respectively FILL_PARENT and WRAP_CONTENT.

like image 33
phogel Avatar answered Sep 19 '22 11:09

phogel