【发布时间】:2017-01-13 03:31:23
【问题描述】:
我将举一个例子来说明更大的意义。
想象一下我的应用有许多 FloatingActionButton。因此,我想创建一种样式并重用它。所以我做了以下事情:
<style name="FabStyle” parent ="Widget.Design.FloatingActionButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_margin">16dp</item>
<item name="app:backgroundTint">@color/accent</item>
<item name="app:layout_anchorGravity">end|bottom</item>
</style>
我遇到的问题是代码没有编译,因为它在抱怨
Error:(40, 5) No resource found that matches the given name: attr 'app:backgroundTint'.
我尝试通过resources 标记引入命名空间,但这不起作用
<resources
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
>
有什么想法可以让它发挥作用吗?
【问题讨论】:
标签: android android-layout android-theme android-styles