android - appcompat-v7 :25. 3.0 : AppCompat does not support the current theme features: { windowActionBar: false, 窗口ActionBarOverlay : false, 。 }

标签 android android-layout

我在运行时收到以下错误,并且 Activity 未启动。错误显示在 setContentView(R.layout.activity_main); 请帮忙。

我正在使用以下库:

compile project(':library')
compile 'com.google.android.gms:play-services-maps:10.2.0'
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:design:25.3.0'
compile 'com.parse:parsetwitterutils-android:1.10.5'
compile files('libs/bolts-android-1.2.0-javadoc.jar')
compile files('libs/bolts-android-1.2.0.jar')
compile files('libs/listviewanimations_lib-core-slh_3.1.0.jar')
compile files('libs/listviewanimations_lib-core_3.1.0.jar')
compile files('libs/listviewanimations_lib-manipulation_3.1.0.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/Parse-1.9.1.jar')
compile files('libs/parse-android-1.13.3.jar')
compile files('libs/ParseCrashReporting-1.9.1.jar')
compile files('libs/picasso-2.5.0.jar')
compile files('libs/universal-image-loader-1.9.3.jar')

错误是:

AndroidRuntime: FATAL EXCEPTION: main Process: com.app.android.hashmap, PID: 26336 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.android.hashmap/com.app.android.hashmap.MainActivity}: java.lang.IllegalArgumentException: AppCompat does not support the current theme features: { windowActionBar: false, windowActionBarOverlay: false, android:windowIsFloating: false, windowActionModeOverlay: false, windowNoTitle: false } at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 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.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:474) at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:328) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.app.android.hashmap.MainActivity.onCreate(MainActivity.java:49) at android.app.Activity.performCreate(Activity.java:6237) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

最佳答案

Android 开发人员在引入时对 AppCompat 对 windowNoTitle 标志进行了更多限制 AppCompatDialogs高度依赖于 windowNoTitle 标志 - 在 22.1.0 版本中。

因此,要解决您的问题,请使用您的主题父级 - Theme.AppCompat.NoActionBar

如果您的要求不适合,请在需要时使用单独的主题 -

例如 -

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

<style name="MyTheme.NoActionBar">
    <!-- both your properties are there -->
    <!-- Remove other ones.. i.e. windowActionBarOverlay and all -->
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

引用 - Android developer's blog

关于android - appcompat-v7 :25. 3.0 : AppCompat does not support the current theme features: { windowActionBar: false, 窗口ActionBarOverlay : false, 。 },我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42831591/

相关文章:

android - 在我的 Android 应用程序中保存状态

java - 在 Camera Intent 后更新 RecyclerView.Adapter

android - 如何将布局与 ImageView 和文本重叠在另一个布局上作为堆栈/堆

android - Facebook 的 Android 应用程序是否使用 ListView 或是否有其他方法在时间轴中创建漂亮的帖子列表?

android - android 中的 Activity 流程 A->B->C->A

java - 如何在 Android 中计算字符串的 SHA-256 哈希?

android - 如何将小部件添加到工具栏并增加其高度

android - ViewStub vs View.GONE vs Inflate vs ViewSwitcher

android - onClick 内部 fragment 给我 NPE

android - 如何在 Jetpack Compose 中按基线对齐行元素