I have created following drawable and set it to a button background from code.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="8dp"/>
<solid android:color="@color/background_profile"/>
<padding android:left="8dp" android:top="7dp" android:right="8dp" android:bottom="6dp" />
</shape>
Kotlin File
btn?.background= resources?.getDrawable(R.drawable.drawable_rewards)
Now i will be getting color from my service, like this "#00000", and I need to update the color in drawable_rewards.xml file.
Is there any way we can change color of drawable file dynamically.
MaterialButton(which has as default rounded corners) and usebackgroundTintto change the background color.