Skip to content
Advertisement

Runtime Change Android material theme

I have one setting screen for change app themes at runtime. I know how to create material design theme. I have create one in my style.xml file

Here is code of my style.xml:

JavaScript

Now I want to change runtime app theme from green to purple or yellow. Anything can any one tell me how can I create a color picker from theme selection and how can I create multiple themes in my style.xml for change it to runtime.

Advertisement

Answer

Dynamic themes using style.xml

Here is my code

Style.xml

JavaScript

themes.xml

JavaScript

v21/style.xml

JavaScript

method for change Theme runtime

JavaScript

after execute this method restart your activity needed

full source code https://github.com/rkoshti/DynamicMaterialTheme

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement