I am trying to set the color of my shape programmatically, inside my drawable I created a rounded shape (rounded_button.xml):
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#00b248" />
<corners android:bottomRightRadius="8dp"
android:bottomLeftRadius="8dp"
android:topRightRadius="8dp"
android:topLeftRadius="8dp"/>
</shape>
And now I want to change it color in my activity.
public void setShapeColor() {
Drawable shapeDrawable = ResourcesCompat.getDrawable(getResources(), R.drawable.rounded_button, null);
shapeDrawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
}
But it does not work and holds still the same color.