0

I want change to my primary colors at runtime. I can change it with custom themes and colors. But I want to change my color from service result not static styles code. Is there any way to change colors.xml programmatically.

I find a solution but that's deprecated now: https://stackoverflow.com/a/34178187/6155031

Cœur
  • 34,719
  • 24
  • 185
  • 251
6155031
  • 3,791
  • 5
  • 22
  • 54
  • 1
    `Is there any way to change colors.xml programatically` you can't change any xml file, as far as i know, and the colors.xml file won't be any different – a_local_nobody Feb 13 '20 at 13:48

1 Answers1

0
  • Create one Singleton class that defines all the colors that you want to change in your app.
  • Set its properties on app load from JSON file obtained from the cloud.
  • In your app, wherever you are using color codes, don't set those values in xml. Set color values in your Java/Kotlin code.
  • I assume you are aware of findViewbyId. :-)
Abhishek
  • 2,786
  • 3
  • 27
  • 43