Change values inside an xml file at runtime

80 Views Asked by At

I have an activity where a user can change the apps color accent. The choosen color is saved inside SharedPreferences.

Instead of having a static value inside the apps colors.xml file I would like to be able to change that by whatever is saved in the apps SharedPreferences.

<color name="colorAccent">#value_from_shared_preferences</color>

I know there are other different ways to use a user specified color as the apps accent color, but I would like to know how to switch out the value inside the apps colors.xml file.

Update: All resource values are constant so it's not possible to change values inside xml file at runtime.

Ref: Programmatically change the value of a color resource obtained from API response

0

There are 0 best solutions below