Reputation: 1859
I'm trying to create a detail view to display mostly textviews. I think that a gridview would be ideal, it doesn't seem to work well with my project which I use ActionBarSherlock for downward compatibility. I've tried using both relative layout and table layout, but I'm not sure how to accomplish what I want.
Here is what I have so far, but I need to have the first column width no greater than the element in it, ie: image, multiline textview, etc..:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/lemon" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5sp" >
<TextView
android:id="@+id/placard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/material"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxLines="5"
android:padding="10sp"
android:textColor="#0000ff"
android:textSize="12sp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/div_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:paddingBottom="5sp"
android:paddingLeft="10sp"
android:paddingTop="5sp"
android:text="@string/division"
android:textColor="#000000"
android:textSize="14sp" />
<TextView
android:id="@+id/division"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:paddingBottom="5sp"
android:paddingLeft="10sp"
android:paddingTop="5sp"
android:textColor="#0000ff"
android:textSize="16sp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/hazards"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5sp"
android:paddingLeft="10sp"
android:paddingTop="5sp"
android:textColor="#0000ff"
android:textSize="14sp" />
</TableRow>
</TableLayout>
Any suggestions would be greatly appreciated.
Upvotes: 1
Views: 1542
Reputation: 63303
I think you are referring to GridLayout
, which was introduced in API 14 (Android 4.0). However, the latest version of the support library includes a library project that you can use to incorporate GridLayout
into your application and have it compatible back to API 7 (Android 2.1).
Because you are trying to make the rows asymmetric from one to the other, I believe GridLayout
may still be your best (only) option.
Here is a link to the support library page.
HTH
Upvotes: 1