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:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line">
<stroke android:width="1dp" android:color="#0000FF"/>
<size android:height="50dp" />
</shape>
The question is, how to make this line vertical?
Yes, there are workarounds, such as drawing a rectangle shape 1px thick, but that complicates the drawable XML, if it consists of multiple <item>
elements.
Anyone had any chance with this?
UPDATE
Case is still unsolved. However,
For anyone on a Android documentation crusade – you might find this useful:
Missing Android XML Manual
UPDATE
I found no other way other than the one that I marked as correct. It does the trick though feels a bit "heavy", thus if you happen to know the answer don't forget to share 😉
Best Answer
Instead of a shape, you could try a
View
:I have only used this for horizontal lines, but I would think it would work for vertical lines as well.
Use:
for a horizontal line.