All of the existing solutions here on SO (1, 2) use styles included in styles.xml or custom XML files. But in my scenario I want to grab the theme data from an API call, convert that JSON into a style and then apply that to my app. How can I accomplish this?
Asked
Active
Viewed 30 times
1 Answers
0
How can I accomplish this?
You can't, using Android styles. The style fields and attributes need to be available at compile for the components that will use them.
You could use a web app framework and use CSS for styling. Further there's nothing stopping you from programmatically calling methods on views to set the color, font, sizes, paddings, etc. You'd need to develop your own framework to apply your style JSON to your view elements however, which is probably not reasonable.

Jeffrey Blattman
- 22,176
- 9
- 79
- 134