how can i use a backgroundresource with variable color

Ginso

hello i have the following drawable:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <solid android:color="#66333333" />
    <padding
        android:left="0dp"
        android:bottom="0dp"
        android:right="0dp"
        android:top="0dp"/>
    <corners android:radius="16dp" />
</shape>

i would like to use it as a background for a view, but set the color of the stroke programatically. is that possible?

amir

A simpler solution nowadays would be to use your shape as a background and then programmatically change its color via:

view.background.colorFilter = BlendModeColorFilter(Color.parseColor("#343434"), BlendMode.SRC_ATOP)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related