Bigflow
Bigflow

Reputation: 3666

how to add vertical lines in shape layout

I got this: enter image description here

And what I want is: enter image description here

Don't mind the color right now. I figured out how to do the horizontal lines, but not the vertical lines. So how to add vertical lines?

This is my row_border.xml (shape):

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <solid android:color="#ffffff" />
    <stroke android:width="1dp" android:color="#99cc00" />

</shape>

Tried this already, but that didn't work:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <solid android:color="#ffffff" />
    <stroke android:width="1dp" android:color="#99cc00" />

    <stroke
        android:angle="90"
        android:width="1dp"
        android:color="#ff0000"
        ></stroke>

</shape>

Upvotes: 0

Views: 674

Answers (2)

Talha
Talha

Reputation: 12717

if you use tablelayout,

1- give TableLayout background android:background="#000000"

2- give your TableRow different background (it will be border color)

3 give your TableRow margin (it will be border width)

left margin = left border

right margin = right border

top margin = top border

bottom margin = bottom border

enter image description here

    <TableLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="#000000" >

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:background="#FFFFFF" >

            <TextView
                android:id="@+id/txt6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/txt5"
                android:text="Hello World 6" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:background="#FFFFFF" >

            <TextView
                android:id="@+id/txt6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/txt5"
                android:text="Hello World 6" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:background="#FFFFFF" >

            <TextView
                android:id="@+id/txt6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/txt5"
                android:text="Hello World 6" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:background="#FFFFFF" >

            <TextView
                android:id="@+id/txt6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/txt5"
                android:text="Hello World 6" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:background="#FFFFFF" >

            <TextView
                android:id="@+id/txt6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/txt5"
                android:text="Hello World 6" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:background="#FFFFFF" >

            <TextView
                android:id="@+id/txt6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/txt5"
                android:text="Hello World 6" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:background="#FFFFFF" >

            <TextView
                android:id="@+id/txt6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/txt5"
                android:text="Hello World 6" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:background="#FFFFFF" >

            <TextView
                android:id="@+id/txt6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/txt5"
                android:text="Hello World 6" />
        </TableRow>
    </TableLayout>

</LinearLayout>

Upvotes: 1

prozhyga
prozhyga

Reputation: 439

Use TableLayout for your situation

Upvotes: 0

Related Questions