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?
Try setting android:stretchColumns="0" or else android:stretchColumns="*" on your TableLayout tag.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With