nhaarman nhaarman - 28 days ago 17
Android Question

How to _really_ programmatically change primary and accent color in Android Lollipop?

First of all, this question asks a very similar question. However, my question has a subtle difference.

What I'd like to know is whether it is possible to programmatically change the

attribute of a theme to an arbitrary color?

So for example, we have:

<style name="AppTheme" parent="android:Theme.Material.Light">
<item name="android:colorPrimary">#ff0000</item>
<item name="android:colorAccent">#ff0000</item>

At runtime, the user decides he wants to use
as a primary color. Ofcourse there's no way I can create themes for all possible colors.

I don't mind if I have to do hacky stuff, like relying on Android's private internals, as long as it works using the public SDK.

My goal is to eventually have the
and all widgets like a
to use this primary color.


Themes are immutable, you can't.