4

我想将 Tint 设置为可绘制的白色,当我将应用程序更改为深色主题时,我不改变什么颜色,所以我这样声明我的颜色。


values/colors.xml
   <color name="white_force">#ffffff</color>

values-night/colors.xml
   <color name="white_force">#ffffff</color>
   

ic_drawable.xml
   <vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="14dp"
    android:height="18dp"
    android:viewportWidth="14"
    android:viewportHeight="18">
        <path
            android:pathData="M12,......,3V15Z"
            android:fillColor="#ffffff" />
    </vector>

layout
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/bookmarkImage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:duplicateParentState="true"
        android:padding="@dimen/ds2_space_2dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:src="@drawable/ic_bookmark_white_14" />

</androidx.constraintlayout.widget.ConstraintLayout>

但是当我将应用程序更改为深色模式时将 Tint 设置为可绘制对象时,它会将颜色 t0 设置为黑色而不是白色。

4

0 回答 0