【问题标题】:Changing negative button color on ListPreference dialog更改 ListPreference 对话框上的负按钮颜色
【发布时间】:2021-11-05 07:28:52
【问题描述】:

我有带有 ListPreference 的 Preference 片段。 当我点击它时,对话框中“取消”否定按钮的文字颜色不好,我需要改变它,我不知道如何。

到目前为止,我明白如果我输入我的主题:

<item name="alertDialogTheme">@style/DialogStyle</item>

这会影响我的对话框,但我不知道应该添加什么样式来使按钮文本改变颜色。 我只需要更改该按钮的颜色即可。

有人知道该怎么做吗?

【问题讨论】:

    标签: android dialog themes android-preferences listpreference


    【解决方案1】:

    只需将以下内容添加到您的styles.xml

    使用您的按钮颜色添加此样式:

    <style name="AlertDialogButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
            <item name="android:textColor">@color/colorAccent</item>
    </style>
    

    最后一步是将这些样式添加到应用的基本主题中(SettingsFragment 从中获取样式的样式:

        <item name="buttonBarPositiveButtonStyle">@style/AlertDialogButton</item>
        <item name="buttonBarNegativeButtonStyle">@style/AlertDialogButton</item>
        <item name="buttonBarNeutralButtonStyle">@style/AlertDialogButton</item>
    

    【讨论】:

      猜你喜欢
      • 2019-11-24
      • 2019-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-21
      相关资源
      最近更新 更多