Sunday, January 11, 2015

How to set Button border color in Android

activity_main.xml code snippet

<Button
 android:id ="@+id/push_button"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Button - Drawable Stroke / Border"
 android:background="@drawable/button_bg_stroke"
 android:padding="15dp"
 />
res/drawable/button_bg_stroke.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape android:shape="rectangle">
        <stroke android:width="2dp" android:color="#8B008B"/>
    </shape>
</item>
</selector>
More android examples