Hi all,
After reading this useful Material design tutorial by @corwin42, I've been playing with custom color themes for a Material design app (Android 5+), and have found (by searching the Android docs and B4A forums, and some trial and error) a few handy XML attributes for setting custom colors for certain Android UI UI elements.
Below is the content of a sample theme.xml file. You can replace the color values (e.g. #f44336) with your own desired values (e.g. using B4A's handy color picker).
The full list of attributes can be found here in the Android docs.
The attributes I've identified so far are included below. Most are self-explanatory, but a few are not, so I've commented these accordingly.
If you've figured out how other color attributes affect UI elements, feel free to add them to this thread.
Cheers!
Dependencies: theme.xml, to be placed in \Objects\res\values-v21 and marked as read-only
Tags: color, Material design, theme, XML, custom
After reading this useful Material design tutorial by @corwin42, I've been playing with custom color themes for a Material design app (Android 5+), and have found (by searching the Android docs and B4A forums, and some trial and error) a few handy XML attributes for setting custom colors for certain Android UI UI elements.
Below is the content of a sample theme.xml file. You can replace the color values (e.g. #f44336) with your own desired values (e.g. using B4A's handy color picker).
The full list of attributes can be found here in the Android docs.
The attributes I've identified so far are included below. Most are self-explanatory, but a few are not, so I've commented these accordingly.
If you've figured out how other color attributes affect UI elements, feel free to add them to this thread.
Cheers!
B4X:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyAppTheme" parent="@android:style/Theme.Material.Light.DarkActionBar">
<item name="android:colorPrimary">#f44336</item> <!-- action bar -->
<item name="android:colorPrimaryDark">#b71c1c</item> <!-- status bar -->
<item name="android:colorAccent">#ff1744</item> <!-- checkboxes,, switches. msgbox buttons in Android 6.x -->
<item name="android:textColorPrimary">#00FF00</item> <!-- msgbox text in Android 6.x -->
<item name="android:textColorSecondary">#FF00FF</item> <!-- inactive editText line,, scrollbar -->
<item name="android:textColor">#000000</item> <!-- menu text,, msgbox title -->
<item name="android:textColorLink">#b71c1c</item>
<item name="android:textColorHighlight">#FF9F9F</item>
</style>
</resources>
Dependencies: theme.xml, to be placed in \Objects\res\values-v21 and marked as read-only
Tags: color, Material design, theme, XML, custom
Last edited: