java - 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.
……
解决方案
查看应用级 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>
推荐阅读
- delphi - 如何将文件名从程序的第二个实例传递到主实例?
- java - Spring Boot 将 camelCase 字符串转换为 Enum
- kubernetes-helm - 等待 helm delete 再继续?
- sql-server - 将集成运行时连接到 azure 数据工厂和权限
- css - 悬停效果闪烁的 CSS 动画,在 FF 中未正确显示
- python - 将行从 CSV 中的 FOR 循环合并到列中
- asp.net-core-mvc - identityserver4 由于证书链中的错误,远程证书无效:untrustedroot
- python - 如何创建无限变量
- css - 更改闪亮仪表板主体特定部分的背景颜色
- python - OSError: [Errno 10048] 每个套接字地址(协议/网络地址/端口)通常只允许使用一次