我已经创建了一个非常简单的Android Studio启动项目(Basic Activity),在res/values/app_styles.xml
中添加简单的样式文件后,我收到了链接错误:
<resources>
<style name="MyFab" parent="Widget.MaterialComponents.ExtendedFloatingActionButton">
<item name="iconTint">?attr/colorOnBackground</item>
<item name="app:fabSize">mini</item>
<item name="app:tint">?attr/colorOnPrimary</item>
</style>
</resources>
app
名称空间似乎不为Android Studio
所知,每个app:**
项都以红色突出显示,并且构建失败并出现链接错误:
Android resource linking failed
xxx.myapp.app-mergeDebugResources-43:/values-w600dp-v13/values-w600dp-v13.xml:6: error: style attribute 'app:attr/fabSize' not found.
xxx.myapp.app-mergeDebugResources-43:/values-w600dp-v13/values-w600dp-v13.xml:7: error: style attribute 'app:attr/tint' not found.
error: failed linking references.
我在这里做错了什么?我应该使用不同的文件名/位置吗?
PS:Android Studio 海豚|Mac x64上的2021.3.1 Patch 1,全新安装。
项目依赖关系:
dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
1条答案
按热度按时间qvtsj1bj1#
必须删除
style
定义中属性名称的app
前缀。请注意,
ExtendedFloatingActionButton
是MaterialButton
的子类,而不是FloatingActionButton
。这意味着适用于FloatingActionButton
的几个属性在ExtendedFloatingActionButton
中有不同的命名或不存在。对于
ExtendedFloatingActionButton
,不存在fabSize
和tint
。