Change an existing topic

I would like to know if (and how) to customize an existing theme.

I'm looking for how I can get a specific attribute (i.e. color) and change it when Activity starts and setContentView() changed theme to setContentView() .

Like setTheme() , but instead of using the resource identifier, use a modified theme.

0
source share
2 answers

Based on further research and Eric's comments, there is still no way to change the topic programmatically. Various topics can be applied programmatically, but not modified. Once the style is set to XML, it cannot be changed.

+2
source

Why not just create your own theme by installing android:parent in the theme you want to copy, and then set your own attributes? This is shown in this documentation , for example:

 <?xml version="1.0" encoding="utf-8"?> <resources> <style name="CodeFont" parent="@android:style/TextAppearance.Medium"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:textColor">#00FF00</item> <item name="android:typeface">monospace</item> </style> </resources> 

In this case, the CodeFont style will be identical to the TextAppearance.Medium style, except for the item specified here. You can do the same with any theme, including the default Golo or Dark theme or something else.

+5
source

All Articles