I would like to add only a bottom and a top border on my Linearlayout
. I have tried to do this :
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:bottom="1dp" android:top="1dp"> <shape android:shape="rectangle"> <solid android:color="#FFFFFF" /> <stroke android:width="1dp" android:color="#000" /> </shape> </item> </layer-list>
But it add a border around the shape..
Could you help me please ?
How do you overlap a linear layout? By assigning margin value "<0" we can overlap the views. But Relative layout is preferable when we need o overlap views. Save this answer.
LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally. You can specify the layout direction with the android:orientation attribute.
I think you can create this drawable and use it as background:
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="rectangle" > <solid android:color="#000"/> </shape> </item> <item android:bottom="1dp" android:top="1dp"> <shape android:shape="rectangle" > <solid android:color="#FFFFFF" /> </shape> </item> </layer-list>
Think of is as drawing a rectangle with border color first and then lay on top of it a rectangle with your background color leaving out 1dp on top and at the bottom.
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