Created
February 3, 2013 14:53
-
-
Save Antarix/4702083 to your computer and use it in GitHub Desktop.
Setting specific border i.e top,bottom,left,right or all for Android layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > | |
<item> | |
<shape | |
android:shape="rectangle"> | |
<!-- Set the border color of your layout here --> | |
<stroke android:width="1dp" android:color="#3AFB03" /> | |
<solid android:color="#3AFB03" /> | |
</shape> | |
</item> | |
<!-- This is for border bottom but | |
you can change this according to your need --> | |
<item android:bottom="4dp" > | |
<shape | |
android:shape="rectangle"> | |
<!-- Set the background color of your layout here --> | |
<stroke android:width="1dp" android:color="#000000" /> | |
<solid android:color="#000000" /> | |
</shape> | |
</item> | |
</layer-list> |
How to give margins from left and right to the border? I don't want border to be end to end. Is there any solution ?
Hope it help you!
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape
android:shape="rectangle">
<!-- Set the border color of your layout here -->
<solid android:color="#3AFB03" />
</shape>
</item>
<!-- This is for border bottom but
you can change this according to your need -->
<item android:right="4dp" >
<shape
android:shape="rectangle">
<!-- Set the background color of your layout here -->
<solid android:color="#000000" />
</shape>
</item>
</layer-list>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is awesome. but i am wondering why would you use a bottom offset value of 4dp for the top layer, when the border width is only 1dp?