升级到AppCompat v22.1.0,现在越来越抛出:IllegalArgumentException:AppCompat不支持当前主题功能不支持、升级到、抛出、现在

由网友(一念执着一生无悔i)分享简介:我刚刚升级我的应用程序使用新近发布的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 follow...

我刚刚升级我的应用程序使用新近发布的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.

这背后的原因主要是为了支持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.

阅读全文

相关推荐

最新文章