java - Android资源链接失败的值,styles.xml
问题描述
所以我想创建一个新的android项目然后突然我有这个错误说Android资源链接失败,下面是我的代码。
样式.xml
resources>
<!-- Base application theme. -->
<style type ="attr" name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item type="attr" name="colorPrimary">@color/colorPrimary</item>
<item type="attr" name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item type="attr" name="colorAccent">@color/colorAccent</item>
</style>
</resources>
显示错误
C:\Users\ASUS\Desktop\Rapih\Re_Mind\app\src\main\res\values\styles.xml:4:5-9:13: AAPT: error: style attribute 'attr/colorPrimary (aka app.com.re_mind:attr/colorPrimary)' not found.
解决方案
使用类似这样的东西不要添加类型属性。这可能会帮助你。
<style name="AppTheme" parent="Base.Theme.MaterialComponents.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
推荐阅读
- jenkins - 升级我的詹金斯服务器
- javascript - react-dropdown - 如果调用 setState,显示不会改变
- remote-debugging - 如何远程调试系统启动组件?
- python - 如何在 Python 中从 PDF 中的文本框中提取文本?
- mysql - 连接来自不同查询的两个 SQL 表
- microclimate - 如何访问微气候中包含的 Git?
- jquery - 成功函数异步问题的jQuery回调
- linux - 如何在 Linux 上转义单引号
- c++ - win32 SetDlgItemText 在 WM_INITDIALOG 中不起作用
- sqlite - SQLite 时间戳转换