Skip to content

Instantly share code, notes, and snippets.

@sababado
Created July 31, 2018 20:25
Show Gist options
  • Save sababado/f3c7727a5cd6e98fddaa7605ce08fbc7 to your computer and use it in GitHub Desktop.
Save sababado/f3c7727a5cd6e98fddaa7605ce08fbc7 to your computer and use it in GitHub Desktop.
Custom Attributes in Themes
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="mp_toolbar_style" format="reference" />
<attr name="mp_header_style" format="reference" />
<attr name="mp_select_color" format="reference" />
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="mp_toolbar_style">@style/Toolbar.Light</item>
<item name="mp_header_style">@style/Header.Light</item>
<item name="mp_select_color">@color/color_light</item>
</style>
<!-- A second theme. No code changes necessary. The only difference is what is defined by the custom attributes. -->
<style name="AnotherTypeAppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="mp_toolbar_style">@style/Toolbar.Dark</item>
<item name="mp_header_style">@style/Header.Dark</item>
<item name="mp_select_color">@color/color_dark</item>
</style>
</resources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment