Possible Duplicate:
Android table view
I have pretty much the same question as was asked here a year ago - how to implement table view widget in a nice manner, like on this screenshot. There wasn't a good answer to that question, so reposting.
I used ListView
with a LinearLayout
as its row, which contains several TextView
elements and an ImageView
. But the trouble is that each row is completely independent from the others in terms of column width. If a column in one row has text that's longer than in another, the two won't be aligned vertically. And GridView
doesn't seem to be appropriate for my case, because it is meant to display homogenious data that is stored in a list and just display it in the columns - like grid of pictures. Any idea how this could be implemented? Thanks.
Update.
OK, I've just found a solution here. In my Linear layout for a table row, despite setting android:layout_weight
I was mistakenly setting android:layout_width
to wrap_content
. Setting it to 0dip
made all TextView's in the LinearLayout have the same width in every row. Here's the example of my row:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:padding="6dip">
<TextView
android:id="@+id/toptext"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="2"
android:textSize="24sp"
/>
<TextView
android:id="@+id/bottomtext"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="3"
android:textSize="24sp"
/>
<ImageView
android:id="@+id/play"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/play_1"
android:clickable="true"
/>
</LinearLayout>