AppCompat不支持当前的主题功能-无效 [英] AppCompat does not support the current theme features - nothing works
问题描述
我正在尝试在我的项目中使用MaterialDesign,但我一直都遇到此错误:
I'm trying to use MaterialDesign in my project but I'm getting this error all the time:
Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features: { windowActionBar: false, windowActionBarOverlay: false, android:windowIsFloating: false, windowActionModeOverlay: false, windowNoTitle: false }
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:371)
at android.support.v7.app.AppCompatDelegateImplV7.initWindowDecorActionBar(AppCompatDelegateImplV7.java:173)
at android.support.v7.app.AppCompatDelegateImplBase.getSupportActionBar(AppCompatDelegateImplBase.java:87)
at android.support.v7.app.AppCompatDelegateImplV7.setSupportActionBar(AppCompatDelegateImplV7.java:197)
at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:99)
at de.memorian.playpal.MainActivity.afterInject(MainActivity.java:72)
我已经阅读了类似的问题,但是每次遇到相同的错误时.
I've reade through similar problems but everytime I'm getting the same error.
MainActivity.java:
@EActivity(R.layout.activity_main)
public class MainActivity extends AppCompatActivity {
@ViewById
protected Toolbar toolbar;
@AfterInject
public void afterInject() {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
}
styles.xml:
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
styles-v21.xml:
style name="AppTheme" parent="AppTheme.Base">
<!-- enable window content transitions -->
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<!-- specify shared element transitions -->
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>
我尝试将父主题设置为.NoActionBar的任何派生版本,但仍然如此.我还尝试过从AndroidAnnotations中删除所有代码,并使用setContentView
和findViewById(R.id.toolbar)
常规方式进行操作.唯一令我困扰的是我将windowNoTitle
设置为true
,但是在日志中却说它是false
.
I've tried setting parent theme to any derivation of .NoActionBar, but still. I've also tried removing all code from AndroidAnnotations and doing it the regular way with setContentView
and findViewById(R.id.toolbar)
. Only thing that bothers me is that I set windowNoTitle
to true
but in the log it says it is false
.
有帮助吗?
推荐答案
对于其他任何有此问题的人,我只是发现了问题: 显然,存在另一个名为"AppTheme"的主题.我不知道为什么和如何,但是更改主题名称可以解决问题.
To anyone else having this problem, I just found the problem: Apparently there exists another theme with name "AppTheme". I don't know why and how, but changing my theme's name solved the problem.
这是我的问题的答案.
这篇关于AppCompat不支持当前的主题功能-无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!