I am working on an android application which is sort of an e-reader but it reads xml files. What I want it to change the background color of the xml file views using a change background button. Quite similar to what Kindle app where when reading an ebook, you can switch the background color to black, white or sepia. I believe this will require changing the whole theme rather than just the background as the text color will also change.
Any help in this regard would be appreciated.
Changing a theme at the runtime is not possible – you’ll have to restart the current Activity and it will use the new Theme.
You can change the background for the Layout and the TextViews by iterating over the views and setting the colors yourself.
If you want to use the Theming method you must do the following: