I have a shape in my drawables:
circle_item.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#ffffff" />
<size
android:width="120dp"
android:height="120dp" />
</shape>
Which is used like so:
icon.xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/backgroundVw"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_gravity="center"
android:scaleType="fitXY"
android:background="@drawable/circle_item"/>
<ImageView
android:id="@+id/icon"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center"
android:layout_margin="8dp"
android:src="@drawable/ic_home" />
</FrameLayout>
The image is changed via code like so:
binding.icon.setImageResource(item!!.Image)
Changing the image works perfectly, but I'm struggling to change the actual color property of circle_item
through the ImageView
This is what I've tried so far:
binding.backgroundVw.background.colorFilter = BlendModeColorFilter(item!!.backgroundColor, BlendMode.SRC_IN)
But this just gives it a weird color which isn't defined anywhere in the project.