升级到AppCompat v22.1.0,现在越来越抛出:IllegalArgumentException:AppCompat不支持当前主题功能 [英] Upgraded to AppCompat v22.1.0 and now getting IllegalArgumentException: AppCompat does not support the current theme features

查看:347
本文介绍了升级到AppCompat v22.1.0,现在越来越抛出:IllegalArgumentException:AppCompat不支持当前主题功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚升级我的应用程序使用新近发布的v22.1.0 AppCompat,我现在得到以下情况例外,当我打开我的应用程序。

I've just upgraded my app to use the newly released v22.1.0 AppCompat and I'm now getting the following exception when I open my app.

Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
        at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:360)
        at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)

如何解决呢?

How do I fix it?

推荐答案

AppCompat现在在主题窗口的标志是什么期待更加严格,更加紧密地匹配什么,你会得到的框架。

AppCompat is now more strict on what it expect in theme window flags, more closely matching what you would get from the framework.

这背后的原因主要是为了支持<一href="https://developer.android.com/reference/android/support/v7/app/AppCompatDialog.html">AppCompatDialogs我们也在此版本中加入。他们大量使用 windowNoTitle 标志,AppCompat previously也没太注意。

The main reason behind this is to support AppCompatDialogs which we were also adding in this release. They make heavy use of the windowNoTitle flag, which AppCompat previously didn't pay much attention to.

因此​​,要解决你的问题,你有两个选择:

So to fix your issue you have two options:

简单的方法是只使用 Theme.AppCompat.NoActionBar 为你的父母的主题。这将永远做正确的事情。

The easy way is to just use Theme.AppCompat.NoActionBar as your parent theme. This will always do the right thing.

如果你不能做到这一点,但(也许你需要支持的行动吧,没有行动起来吧),你应该做到以下几点:

If you can't do that though (maybe you need to support action bar and no action bar), you should do the following:

<style name="MyTheme" parent="Theme.AppCompat">
    ...
</style>

<style name="MyTheme.NoActionBar">
    <!-- Both of these are needed -->
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

您应该回到正常轨道了。

You should be back on track now.

这篇关于升级到AppCompat v22.1.0,现在越来越抛出:IllegalArgumentException:AppCompat不支持当前主题功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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