Skip to content

Instantly share code, notes, and snippets.

@ryanbateman
Created July 18, 2012 17:48
Show Gist options
  • Save ryanbateman/3137708 to your computer and use it in GitHub Desktop.
Save ryanbateman/3137708 to your computer and use it in GitHub Desktop.
Decent-looking Android buttons using only shape drawables
<?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="@color/darkorange" />
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<corners
android:bottomLeftRadius="13dp"
android:bottomRightRadius="13dp"
android:topLeftRadius="13dp"
android:topRightRadius="13dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle" >
<stroke
android:width="1dp"
android:color="@color/lightorange" />
<gradient
android:angle="270"
android:endColor="@color/lightorange"
android:startColor="@color/darkorange" />
<corners
android:bottomLeftRadius="12dp"
android:bottomRightRadius="12dp"
android:topLeftRadius="12dp"
android:topRightRadius="12dp" />
</shape>
</item>
</layer-list>
<?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="@color/darkorange" />
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<corners
android:bottomLeftRadius="13dp"
android:bottomRightRadius="13dp"
android:topLeftRadius="13dp"
android:topRightRadius="13dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle" >
<stroke
android:width="1dp"
android:color="@color/lightorange" />
<gradient
android:angle="270"
android:endColor="@color/darkorange"
android:startColor="@color/lightorange" />
<corners
android:bottomLeftRadius="12dp"
android:bottomRightRadius="12dp"
android:topLeftRadius="12dp"
android:topRightRadius="12dp" />
</shape>
</item>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="lightorange">#d98800</color>
<color name="darkorange">#b44a00</color>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="@drawable/button_background_pressed" />
<item android:drawable="@drawable/button_background_default" />
</selector>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment