无法更改Android Studio上FloatingActionButton布局文件中的图标颜色

无法更改Android Studio上FloatingActionButton布局文件中的图标颜色,android,android-layout,floating-action-button,material-components-android,Android,Android Layout,Floating Action Button,Material Components Android,因此,我有一个布局文件,其骨架如下: <layout> <CoordinatorLayout> <AppBarLayout> ... some tags and stuff ... </AppBarLayout> <NestedScrollView> .... nested scroll view stuff </NestedScrollView> <!--

因此,我有一个布局文件,其骨架如下:

<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 ....

关于这件事有什么线索吗


向你们大家致以最良好的祝愿:-)

我不确定您真正想要的效果是什么,但您可以尝试评论或删除这一行:

android:backgroundTint="@color/someDarkBlueColor"

或者,如果您使用
com.google.android.material
包中的
FloatingActionButton
,则应添加
app:tint
,而不是
android:tint
。然后在xml中,您应该使用
app:tint=“@color/colorWhite”
而不是使用
android:tint=“@color/colorWhite”
右侧是:



app:srcCompat
非常重要。

您是否尝试使用app:tint=“@color/colorWhite”而不是“android:tint”?如果你使用com.google.android.material包中的floatingAction按钮,你应该添加app:tint而不是android:tintPerfect!那就对了。谢谢!我想知道为什么它只是忽略了我在ic_white_camera.xml中添加的白色…(现在…如何将这个问题标记为已回答???)我添加了这个作为答案。如果你能解决这个问题,你可以把这个标记为已回答。我希望相机是白色的。Khalana Chinthaka为我解决了这个问题。
android:backgroundTint="@color/someDarkBlueColor"
  <com.google.android.material.floatingactionbutton.FloatingActionButton
      app:srcCompat="@drawable/ic_white_camera"
      app:tint="@color/colorWhite"
      app:backgroundTint="@color/someDarkBlueColor"/>