Imran Hakeem
Imran Hakeem

Reputation: 1

Cannot add vertical line(divider) in TableLayout Android

i need to add vertical border in TableLayout. I have searched the internet and tried many solutions but none of them are working. Below is my code:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/row"
android:layout_gravity="center"
android:showDividers="beginning"
android:orientation="horizontal"
android:stretchColumns="1"
android:background="@drawable/custom_background">

<TableRow>
    <TextView
        android:text="Name"
        android:padding="3dip" />

    <TextView
        android:text="Imran"
        android:gravity="left"
        android:padding="3dip" />
</TableRow>

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

<TableRow>
    <TextView
        android:text="Name"
        android:padding="3dip" />

    <TextView
        android:text="Test"
        android:gravity="left"
        android:padding="3dip" />
</TableRow>

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

<TableRow>
    <TextView
        android:text="Name"
        android:padding="3dip" />

    <TextView
        android:text="Test"
        android:gravity="left"
        android:padding="3dip" />
</TableRow>

I am getting this with the above code TableLayout

But i need to add vertical line(Border) in front of "Name". I have tried adding View between two textViews in a TableRow but that stretches the whole column even if i set the width to 1dip. Any Suggestions on how to add the vertical border?

Upvotes: 0

Views: 231

Answers (1)

Vishal Kumar Sahu
Vishal Kumar Sahu

Reputation: 1396

I have no idea about android except that I have android developer with me. You can have verticle line by a box having width of 1px (or the width you desire) infront of the name. Hope this works for you.

Upvotes: 0

Related Questions