I\'m trying to figure out how to define a vertical line (1dp thick) to be used as a drawable.
To make a horizontal one, it\'s pretty straightforward:
I think this is the simplest solution:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:gravity="center">
<shape android:shape="rectangle">
<size android:width="1dp" />
<solid android:color="#0000FF" />
</shape>
</item>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="-3dp"
android:left="-3dp"
android:top="-3dp">
<shape android:shape="rectangle">
<solid android:color="@color/colorPrimary" />
<stroke
android:width="2dp"
android:color="#1fc78c" />
</shape>
</item>
</layer-list>
You can use a shape but instead of a line make it rectangle.
android:shape="rectangle">
<stroke
android:width="5dp"
android:color="#ff000000"
android:dashGap="10px"
android:dashWidth="30px" />
and In your layout use this...
<ImageView
android:layout_width="7dp"
android:layout_height="match_parent"
android:src="@drawable/dashline"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layerType="software"/>
You might have to play with the width, depending on the size of the dashes, to get it into a single line.
Hope this helps Cheers