如何更改可绘制ImageView的颜色android kotlin

问题描述 投票:0回答:1

我的

vector
包中有一个
drawable
图标
ic_vector_point_image
:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="10dp"
    android:height="10dp"
    android:viewportWidth="3"
    android:viewportHeight="3">
  <path
      android:pathData="M1.5,1.5m-1.5,0a1.5,1.5 0,1 1,3 0a1.5,1.5 0,1 1,-3 0"
      android:fillColor="#4C55E4"/> --- blue color
</vector>

然后我将这个

vector
图标与我的
ImageView
:

<ImageView
        android:id="@+id/point"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="3.7dp"
        android:src="@drawable/ic_vector_typing_indicator_point"
        app:layout_constraintBottom_toBottomOf="@id/typing_text"
        app:layout_constraintStart_toStartOf="parent"
        tools:ignore="ContentDescription" />

我需要为此

argb
设置
drawable
颜色,如下所示:
imageView.setColor(Color.argb())
。我该怎么做?

android kotlin android-layout android-drawable android-vectordrawable
1个回答
0
投票

您可以像这样更改图像视图的色调:

imageView.setColorFilter(Color.argb(255, 255, 255, 255));
// 白色

© www.soinside.com 2019 - 2024. All rights reserved.