【问题标题】:Prevent my android:theme from modifying dialogs?防止我的 android:theme 修改对话框?
【发布时间】:2014-12-31 12:26:59
【问题描述】:

我的主题为我的应用程序提供了黑色文本和黄色背景,这很有效,但我注意到它也影响了 AlertDialogs 并使它们看起来有问题。

我想确保我的应用主题只修改活动和片段的父布局,而不是对话框或 toast。如何恢复它们以便它们使用手机的默认样式?

这就是我正在尝试的:

<style name="MyTheme" parent="android:style/Theme.Holo.NoActionBar.Fullscreen">
    <!-- Colors -->
    <item name="android:textColor">#000000</item>
    <item name="android:background">#fffdf12a</item>

    <!-- Restore Dialogs to default style -->
    <item name="android:alertDialogStyle"></item>
</style>

【问题讨论】:

    标签: android android-fragments styles themes


    【解决方案1】:

    据我所知,您不能对 System 创建的对话框执行此操作,例如首选项中的对话框,但您可以更改 您从头开始创建的对话框

    这是我从另一个答案中找到的:

    protected AlertDialog(Context context) {
       this(context, com.android.internal.R.style.Theme_Dialog_Alert);
    }
    
    public Builder(Context context) {
       this(context, com.android.internal.R.style.Theme_Dialog_Alert);
    }
    

    您可以看到这些值是硬编码,因此无法更改

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-11
      相关资源
      最近更新 更多