如何在Android的Material主题警报中更改强调颜色?

5

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. 我没有使用appcompat库,为了这个问题的目的,您应该假装我不支持低于Lollipop的任何内容。

1个回答

5
我假设你所说的“alert”是指一个对话框(Dialog)。这些受不同主题引用的控制:
<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>

1
它能工作,但使用的是colorAccent而不是colorPrimary。 - Grishka

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接