【问题标题】:android.app.AlertDialog custom themes not workingandroid.app.AlertDialog 自定义主题不起作用
【发布时间】:2019-03-26 21:35:00
【问题描述】:

我想更改默认的 AlertDialog 主题。

我发现的例子都没有。这是我正在做的事情:

<style name="LightTheme" parent="Theme.AppCompat.Light.NoActionBar">
    ...
    <item name="alertDialogTheme">@style/MyCustomDialog</item>
</style>

<style name="MyCustomDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="android:background">#000000</item>
    <item name="android:textColor">#FFFFFF</item>
</style>

我是不是做错了什么?

【问题讨论】:

  • 在您使用此主题的位置添加布局 (xml) 或课程代码。
  • 这不应该改变整个项目的主题吗?我正在使用new AlertDialog.Builder(context)
  • 您的 LightTheme 是主应用主题吗(您正在使用例如在 Manifest 中)?
  • 是的。 android:theme="@style/LightTheme"

标签: android themes android-alertdialog android-theme android-styles


【解决方案1】:

好的。我有一个解决方案。

您必须将android.app.AlertDialog 替换为android.support.v7.app.AlertDialog 并且在您的自定义主题中必须设置&lt;item name="colorAccent"&gt;@color/colorAccent&lt;/item&gt;

【讨论】:

    猜你喜欢
    • 2011-10-15
    • 2016-06-15
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 2020-10-22
    • 2013-10-09
    • 1970-01-01
    相关资源
    最近更新 更多