如何在主题活动中显示 Holo(深色)AlertDialog? [英] How to show a Holo (dark) AlertDialog in a themed activity?

查看:28
本文介绍了如何在主题活动中显示 Holo(深色)AlertDialog?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用内容包装器:

I have tried to use a content wrapper:

ContextThemeWrapper wrapper = new ContextThemeWrapper(this, android.R.style.Theme_Holo_Dialog);
AlertDialog.Builder builder = new AlertDialog.Builder(wrapper);

这样做的结果,是一个黑白色混合的对话框,太可怕了.

The result of this, is a dialog box of a mix of both dark and white, horrible.

在过去的 2 小时内,我也尝试过使用自定义样式等,但没有成功.我相信解决方案一定非常简单,我只需要让 AlertDialog Builder 认为我的活动是 Holo 黑暗主题即可.但是如何?

I have also tried using customized styles and etc in the past 2 hours, no luck. I believe the solution must be very simple, I just need to trick the AlertDialog Builder to think my activity is Holo dark themed. But how?

这就是我为我的活动设置主题的方式,也许我在那里做错了:

This is how I themed my activity, maybe I did something wrong there:

<style name="ThemeSolarizedLight" parent="android:Theme.Holo.Light">
    <item name="android:background">@color/light_yellow</item>
    <item name="android:textColor">that No Wi-fi color you see up there</item>
</style>

推荐答案

您正在使用操作栏的主题,而不是使用为对话框制作的主题

You are using the actionbar's theme instead use the theme made for dialog

示例:

ContextThemeWrapper wrapper = new ContextThemeWrapper(this, android.R.style.Theme_Holo_Dialog;);

这篇关于如何在主题活动中显示 Holo(深色)AlertDialog?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆