Skip to content

Instantly share code, notes, and snippets.

@SpaceBison
Last active May 5, 2016 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SpaceBison/9441bb4e6b8e0d366e30aa7dd4373764 to your computer and use it in GitHub Desktop.
Save SpaceBison/9441bb4e6b8e0d366e30aa7dd4373764 to your computer and use it in GitHub Desktop.
Material Colored Buttons
<!-- res/color/color_button_background.xml -->
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Disabled -->
<item android:state_enabled="false"
android:color="@color/disabled_button"/>
<!-- Enabled -->
<item android:color="@color/colorPrimary"/>
</selector>
<!-- res/color/color_button_text.xml -->
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Disabled -->
<item android:state_enabled="false"
android:color="@color/disabled_button_text"/>
<!-- Enabled -->
<item android:color="@color/white"/>
</selector>
<!-- apply style to button -->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:theme="@style/StyledButton"/>
<!-- put this in res/values/styles.xml -->
<style name="StyledButton" parent="Widget.AppCompat.Button.Colored">
<item name="android:textStyle">bold</item>
<item name="android:textColor">@drawable/color_button_text</item>
<item name="colorButtonNormal">@drawable/color_button_background</item>
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment