android - 如何更改 FloatingActionButton 中矢量资源的颜色?
问题描述
这是我的 FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/white"
android:focusable="true"
android:src="@drawable/ic_camera_24"
android:tint="@color/green"
app:fabSize="mini"
app:rippleColor="@color/green" />
我尝试更改布局 ic_camera_24.xml 中的颜色,但仍然无法正常工作,我该如何解决?
祝大家拥有美好的一天!
解决方案
用app:srcCompat和app:tint试试这个:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/white"
android:focusable="true"
app:srcCompat="@drawable/ic_camera_24"
app:tint="@color/green"
app:fabSize="mini"
app:rippleColor="@color/green" />
源代码:https ://material.io/components/buttons-floating-action-button/android#mini-fabs
推荐阅读
- php - 当从 shell for loop 内部调用 php getmxrr() 时,性能会下降
- vue.js - VueJS如何在v-html指令中附加div
- hadoop - Hadoop 集群 - “hadoop”用户 ssh 通信
- python - Tensorflow:如何平铺以特定顺序重复的张量?
- javascript - 嵌套异步循环中的节点 MySQL 两个查询
- bash - grep 文件中的模式,打印模式而不是匹配的字符串
- c++ - 将有序数组转换为二叉树:代码中的运行时错误
- java - RestFB 获得对话
- vba - 保存没有宏的 Excel 文件。Excel VBA代码
- ios - CoreNFC 未在 iOS 中读取 UID