首页 > 解决方案 > Navigation Drawer Activity 新项目显示一些渲染错误

问题描述

这是预览

首次使用 Navigation Drawer 活动,在新打开的项目中显示这些错误

Failed to find style 'coordinatorLayoutStyle' in current theme 

The following classes could not be instantiated:
- android.support.design.widget.CoordinatorLayout (Open Class, Show            Exception, Clear Cache)
- android.support.design.widget.AppBarLayout (Open Class, Show Exception,    Clear Cache)
 Tip: Use View.isInEditMode() in your custom views to skip code or show    sample data when shown in the IDE.  If this is an unexpected error you can    also try to build the project, then manually refresh the layout.  Exception    Details java.lang.ClassNotFoundException:    android.view.View$OnUnhandledKeyEventListener.

……

标签: javaandroid

解决方案


查看应用级 gradle 文件中的依赖项

implementation 'com.android.support:appcompat-v7:27.1.1'

这可以为你工作。还记得google()在项目级别添加 gradle 文件,更多信息可以在这里找到

您还可以查看 values 文件夹中的样式文件,其中声明的样式应该是这样的

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

推荐阅读