java - 如何使用价值'?attr / actionButtonStyle制作'风格'
问题描述
[/storage/emulated/0/.sketchware/data/743/files/resource/layout/custom_action_item_layout.xml:2:错误:错误:找不到与给定名称匹配的资源(在“样式”中,值为“?attr/ actionButtonStyle')., , /storage/emulated/0/.sketchware/data/743/files/resource/menu/main_menu.xml:6: 错误:在包'com.my.中找不到属性'actionLayout'的资源标识符。 newproject9', , /storage/emulated/0/.sketchware/data/743/files/resource/menu/main_menu.xml:6: 错误:在包'com.my.newproject9'中找不到属性'showAsAction'的资源标识符, ]
解决方案
可能您已经actionButtonStyle
从某处引用了 attr,并且此属性未在您的 App 主题中设置。
假设您正在为您的应用程序使用材料主题,首先,为您的按钮创建一个主题。以下是一个示例,您可以根据需要对其进行自定义:
<style name="Widget.App.Button" parent="Widget.MaterialComponents.Button">
<item name="materialThemeOverlay">@style/ThemeOverlay.App.Button</item>
<item name="android:textAppearance">@style/TextAppearance.App.Button</item>
<item name="shapeAppearance">@style/ShapeAppearance.App.SmallComponent</item>
</style>
现在,在您的应用主题中,将此属性值设置为新主题:
<!--Your app theme might be different than the following, just put that attribute inside-->
<style name="Theme.App" parent="Theme.MaterialComponents.*">
...
<item name="actionButtonStyle">@style/Widget.App.Button</item>
</style>
希望这可以帮助。
推荐阅读
- android - Picasso 不将 url 加载到 ImageView 传递值时抛出构造函数
- sql - 创建了一个包含主键列和两个外键列的连接表,而不是拉入数据
- c# - 无法创建目录:System.UnauthorizedAccessException 错误
- macos - 如何在 macOS 上获取 awk 版本?
- r - 使用 r 中其他两列的 group_by 计算行数
- haskell - 如何修复haskell中的“函数中的非详尽模式”错误?
- java - 如何删除JPanel内图像和文本之间的空白?
- regex - 如何匹配不包含特定字符串的字符串
- android - 如何使用 kotlin 将一列复制到 SQlite 数据库中的另一列
- c++ - 写入开头后附加到二进制文件