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 arrangement of colored silver, it covers only 3/4 of the table row. If I put the LinearLayout in horizontal orientation, it will be fully deployed, but if I change it to vertical, the same problem will occur. I need a relative layout in the table row, because I need something like this:

Value
Read more Read more.

Any ideas on how the relative layout will span the table row?

+6
android relativelayout tablelayout tablerow
source share
3 answers

Try setting android: stretchColumns = "0" or else android: stretchColumns = "*" in the TableLayout tag.

+12
source share

So, I temporarily switched from this problem, but it reappeared. I repeat, the problem I saw was that the relative layout inside the table row would not cover the entire row, regardless of why I set its width and height. I found a solution that forces any layout to completely cover the row of the table (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"> 

Please note that this directly contradicts what is indicated in the java docs table row:

TableRow children do not need to specify layout_width and layout_height attributes in an XML file. TableRow always applies these values ​​will be respectively FILL_PARENT and WRAP_CONTENT.

+6
source share

You must put the android:background="@color/silver" attribute in the TableRow.

I had the same issue with LinearLayout inside ScrollView.

Hope this helps,

Lint

+1
source share

All Articles