android - Can i change accent color (AppCompat) programmatically? -


i have:

<style name="apptheme" parent="theme.appcompat">     <item name="coloraccent">@color/mycolor</item> </style> 

but want allow user change accent color. can appcompat?

no can't, because accent color defined in theme , themes read-only in android.

the thing can switch themes or set color of each component manually.

note: can apply theme portion of ui instead of whole activity in order change accent color (or other things) locally. so, can use android:theme attribute in xml layout appcompat library, or can inflate layout providing contextthemewrapper context layoutinflater.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -