【发布时间】:2020-12-15 19:13:33
【问题描述】:
所以,我有这个带有以下骨架的布局文件:
<layout>
<CoordinatorLayout>
<AppBarLayout>
... some tags and stuff ...
</AppBarLayout>
<NestedScrollView>
.... nested scroll view stuff
</NestedScrollView>
<!-- Finally! Here comes.... -->
<FloatingActionButton>
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="8dp"
android:backgroundTint="@color/someDarkBlueColor"
android:tint="@color/colorWhite"
android:src="@drawable/ic_white_camera" />
... closing tags and stuff ....
ic_white_camera如下:
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="200dp" android:height="200dp" android:viewportWidth="24.0" android:viewportHeight="24.0">
<path android:fillColor="@color/colorWhite" android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0"/>
<path android:fillColor="@color/colorWhite" android:pathData="M9,2L7.17,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2L9,2zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z"/>
</vector>
@color/colorWhite 是.. 你猜对了。白...
然而android坚持把相机图标渲染成黑色!
我已尝试添加android:tint="@color/colorWhite"。没办法。。
添加了android:foregroundTint="@color/colorWhite" 和... Nada!
仍然得到这个:
这有什么线索吗?
向你们致以最诚挚的问候.. :-)
【问题讨论】:
-
您是否尝试使用 app:tint="@color/colorWhite" 而不是 "android:tint"?如果你使用 com.google.android.material 包中的 FloatingActionButton,你应该添加 app:tint 而不是 android:tint
-
完美!那钉了它。非常感谢!我想知道为什么它只是忽略了我在 ic_white_camera.xml 中添加的白色......
-
(现在...如何将此问题标记为已回答??)
-
我添加了这个作为答案。如果您能解决问题,您可以将此标记为已回答。
标签: android android-layout floating-action-button material-components-android