Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the accent color in Android's Material theme alerts?

I have the following theme declaration in my values-v21 folder:

<style name="BaseTheme" parent="android:Theme.Material.Light.DarkActionBar">
        <item name="android:colorPrimary">@color/brand_primary</item>
        <item name="android:colorPrimaryDark">@color/status_bar_bg</item>
        <item name="android:colorAccent">#FF00FF</item>
        <item name="android:colorControlHighlight">#0000FF</item>
</style>
These colors apply to everything as expected (e.g. status bar or action mode) but all the controls (check boxes, radios, and buttons) in alerts still have the default turquoise color. Is there a way to colorize them too?

p.s. I'm not using the appcompat library, for the purpose of this question you should pretend I don't support anything below Lollipop.

like image 674
Grishka Avatar asked Nov 14 '14 20:11

Grishka


People also ask

How do I change the accent color?

Android system accent colors can be changed by going to Settings > Wallpaper & style > Basic colors and picking your favorite color. You can also go to Wallpaper colors to let Android pick the colors based on your wallpaper.

How do I change the accent color on my Samsung 10 android?

Go to Settings->System->Developer options–>Scroll down to accent colors. Now, choose the accent color that you want to enable and you are done.

What is accent color in material?

Accent Color refers to a color used to emphasize key parts of the UI, such as the active tab, focused input texts, checked boxes, etc. The Material Theme plugin enables this feature in the IDE and gives the ability to customize it to your heart's content.


1 Answers

I assume by "alert" you mean a Dialog. These are controlled by a different theme reference:

<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
    <item name="android:alertDialogTheme">@style/BaseDialogTheme</item>
</style>

<style name="BaseDialogTheme" parent="android:Theme.Material.Dialog.Alert">
    <item name="android:colorPrimary">...</item>
</style>
like image 69
Jeffrey Mixon Avatar answered Oct 03 '22 03:10

Jeffrey Mixon