2

This is how my style.xml looks like:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">#2196F3</item>
    <item name="colorPrimaryDark">#1976D2</item>
    <item name="colorAccent">#FF4081</item>
    ...........
</style>

I want to override the "colorPrimary" and "colorAccent" programmatically (using java) from Appliation class or Activity class. Can anyone help me how I can make it possible?

Note: I don't want to create multiple style.xml files for different themes. I just want to override the basic colors programmatically e.g. I want to "colorPrimary" to #FF0000 from #2196F3.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
dev_android
  • 8,698
  • 22
  • 91
  • 148
  • 1
    AFAIK its not possible to change only colors . You can have a look int this [Answer](https://stackoverflow.com/questions/34735500/change-theme-color-at-runtime-in-android). – ADM Jan 12 '18 at 09:15
  • Why don't you just change the colours in style.xml? – Thomas Mary Jan 12 '18 at 10:59
  • 1
    Because I need dynamic colors themes for different users, who can dynamically create it, not select from few options. – dev_android Jan 16 '18 at 12:17

0 Answers0