I've describef properties of my objects (nevermind what the object is) in styles.xml. I would like to change these properties dynamically in styles.xml.
Does anybody know how can I do that?
You can do that like:
In Activity:
this.setTheme(R.style.ThemeRed);
In styles.xml:
<resources>
<style name="ThemeBlack" parent="@android:style/Theme">
<item name="android:textColor">#FFFFFF</item>
<item name="android:typeface">sans</item>
<<item name="android:background">#999999</item>
<item name="android:textSize">16sp</item>
</style>
<style name="ThemeRed" parent="@android:style/Theme">
<item name="android:textColor">#FFFFFF</item>
<item name="android:typeface">sans</item>
<item name="android:background">#c81111</item>
<item name="android:textSize">16sp</item>
</style>
</resources>
I am seeing contradicting answers to this question. This says yes, but this says no. I looked at the android docs for the View and can not find any setStyle method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With