I have found that to add borders around views I can use the following code as a background for the view:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<stroke android:width="1dp" android:color="#999999" />
<padding android:left="1dp" android:top="1dp" android:right="1dp"
android:bottom="1dp" />
</shape>
But what if I want a border just for bottom, or top or right or left? I tried the following:
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke android:color="#000"/>
</shape>
but when I set it as background
android:background="@drawable/my_border"
it draws the line at the middle of the view, so I have a strike-through effect. Is there any way I can draw this line at the bottom or at the top or make it vertical?
In WPF we have a relative coordinates for shapes, so I can offset lines as needed. Is there something similar on Android? If we don't have borders, at least we should have good line shape drawing tools, so we can draw borders as needed. Do Android developers plan to do something about it?
For border line on the top or bottom of you view, you can check my previous answer here. It is a very simple way.
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