Jeena
Jeena

Reputation: 31

Displaying table columns vertically with divider android

I am new to android and I want to create a simple table with 2 columns in it. so i looked for some example and found nice one and created table like this:

<TableRow>
    <TextView
        android:layout_column="1"
        android:text="Open..."
        android:padding="3dip" />
    <TextView
        android:text="Ctrl-O"
        android:gravity="right"
        android:padding="3dip" />
</TableRow>

<TableRow>
    <TextView
        android:layout_column="1"
        android:text="Save..."
        android:padding="3dip" />
    <TextView
        android:text="Ctrl-S"
        android:gravity="right"
        android:padding="3dip" />
</TableRow>

Now i get table with two rows and each row has two columns without any separator. I want to have a divider in two columns like any normal table. Can anyone please help me with it. Tnx in advance...

Upvotes: 1

Views: 6997

Answers (2)

Bachi
Bachi

Reputation: 6517

Another simple solution as suggested in the android.com tutorials: Simply add an empty view with a background as divider:

<View
    android:layout_height="2dip"
    android:background="#FF909090" />

Source: http://developer.android.com/resources/tutorials/views/hello-tablelayout.html

Upvotes: 2

jkhouw1
jkhouw1

Reputation: 7350

one thing you could do is create a png of a vertical divider and place it between your tablerows.

<TableRow>
    <TextView
        android:layout_column="1"
        android:text="Save..."
        android:padding="3dip" />
<ImageView android:layout_width="3dp" android:layout_height="fill_parent" android:id="@+id/imageView1" android:src="@drawable/icon"/>

    <TextView
        android:text="Ctrl-S"
        android:gravity="right"
        android:padding="3dip" />
</TableRow>

and set the source of the of the image view to your image.

Upvotes: 1

Related Questions