应用程序兼容性对话主题,误色的标题栏 - 错误? [英] AppCompat Dialog Theme with Mis-colored titlebar - Bug?

查看:199
本文介绍了应用程序兼容性对话主题,误色的标题栏 - 错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 LoginActivity 在这里我使用程序兼容性的主题是这样的:

I have a LoginActivity where I use an AppCompat theme like this:

 <activity
            android:name=".LoginActivity"
            android:theme="@style/Theme.AppCompat.Light.Dialog"
            android:label="Login" />

我知道,因为这个职位的谷歌还没有被添加在应用程序兼容性库对话框材质的主题,所以我认为它会依傍全息。相反,这是我得到:

I am aware that as of this post Google has not yet added Material Themes in AppCompat library for DIALOGS, so I assumed it will fall back on Holo. Instead, this is what I get:

请记住,我没有使用程序兼容性 工具栏。在活动,我也不让到动作条的参考。什么你在上面看到的是默认的行为,但我想不出它是从哪里过来。这是一个bug吧?

Keep in mind, I am not using the AppCompat toolBar. In the Activity, I am not even making a reference to the ActionBar. What you see above is default behavior, yet I cannot figure out where it is coming from. Is this a bug perhaps?

(另外,的EditText 字段不被着色与主色为应用程序。)

(Also, the EditText fields are not being colored with the Primary color for the app.)

推荐答案

注意:看不到我最后的编辑为可能是最好的解决方案

有关它的价值,我认为这是一个错误。然而,我发现了一个有效的解决方法是使用 @风格/ Base.Theme.AppCompat.Light.Dialog.FixedSize 。根据您的截图,我认为这会为你工作,以及。但是,我还没有测试调色板着色呢。

For what it's worth, I do think this is a bug. However, a valid workaround that I discovered is to use @style/Base.Theme.AppCompat.Light.Dialog.FixedSize. Based on your screenshot I think this will work for you as well. However, I have not tested palette coloring yet.

从我可以在我的测试告诉,这扩展了灰色边框,同时还允许您使用应用程序兼容性和V21。

From what I can tell in my testing, this extends the gray border while still allowing you to use AppCompat and v21.

编辑:一个副作用是现在看来,所有的对话活动的大小相同,这可能不是为你工作。另外,我还没有想出如何删除标题 - requestWindowFeature和supportRequestWindowFeature与Window.FEATURE_NO_TITLE似乎导致

one side-effect is it now appears that all dialog activities are the same size, which may not work for you. Also, I haven't figured out how to remove the title - requestWindowFeature and supportRequestWindowFeature with Window.FEATURE_NO_TITLE seems to be causing

java.lang.RuntimeException: Unable to start activity ComponentInfo{myclass}:
android.util.AndroidRuntimeException: requestFeature() must be called before adding content

尽管我之前已经和super.onCreate后的setContentView之前肯定尝试过

even though I've tried it before and after super.onCreate and definitely before setContentView

编辑#2:删除通过XML主题化的作品标题,既然你有没有标题,没有奇怪的灰色的框,不用担心,这意味着你可以放置FixedSize设置,对话框将包裹它的内容像它那样在更早版本。

Edit#2: Removing the title via XML theming works, and since you have no title there is no bizarre gray box to worry about, which means you can drop the FixedSize setting and the dialog will wrap it's content like it did in earlier versions.

<style name="MyActivityDialogTheme" parent="Base.Theme.AppCompat.Light.Dialog">
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
</style>

编辑#3:你也可以简单地删除灰色背景 - 这可能是最好的解决方案,因为它不需要基础。 preFIX

<style name="MyTitledActivityDialogTheme" parent="Theme.AppCompat.Light.Dialog">
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowTitleBackgroundStyle">@android:color/transparent</item>
    <item name="windowActionBar">false</item>
</style>

这篇关于应用程序兼容性对话主题,误色的标题栏 - 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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