Reputation: 1937
I have:
<style name="AppTheme" parent="Theme.AppCompat">
<item name="colorAccent">@color/myColor</item>
</style>
But I want to allow the user to change the accent color. Can I do it with AppCompat?
Upvotes: 6
Views: 4477
Reputation: 12949
No you can't, because the accent color is defined in the theme and themes are read-only in Android.
The only thing you can do is switch themes or set the color of each component manually.
Note: you can apply a theme to a portion of UI instead of the whole Activity in order to change the accent color (or other things) locally. To do so, you can use the android:theme
attribute in your XML layout with the AppCompat library, or you can inflate a layout by providing a ContextThemeWrapper
as context to your LayoutInflater
.
Upvotes: 6