I would like to draw a line right in the middle of a layout and use it as a separator of other items like TextView. Is there a good widget for this. I don't really want to use an image as it would be hard to match the other components to it. And I want it to be relatively positioned as well. Thanks
quadTo(mX, mY, (x + mX)/2, (y + mY)/2); You will be able to draw straight lines.
That line historically represents the margin of A4 paper, which is useful only if you need to print the code. Old school says that you should keep your code inside that margin, to guarantee much portability.
I usually use this code to add horizontal line:
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="@android:color/darker_gray"/>
To add vertical separator, switch the layout_width
and layout_height
values
To improve on the answers provided by Alex Kucherenko and Dan Dar3
I added this to my styles:
<style name="Divider"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">1dp</item> <item name="android:background">?android:attr/listDivider</item> </style>
Then in my layouts is less code and simpler to read.
<View style="@style/Divider"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With