I have an ImageButton:
<ImageButton
android:layout_width="100dp"
android:layout_height="100dp"
app:srcCompat="@drawable/round_color"
android:layout_below="@+id/lamps_list_room"
android:layout_alignStart="@+id/lamps_list_room"
android:layout_marginStart="69dp"
android:layout_marginTop="62dp"
android:id="@+id/color_picker_button"
android:background="@color/colorPrimaryDark"/>
And a shape:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<corners android:radius="100dp" />
<stroke
android:color="#FFFFFF"
android:width="2px">
</stroke>
</shape>
What is the best way to change the solid color of the shape?
ImageButton imageButton = (ImageButton) ((Activity) mContext).findViewById(R.id.color_picker_button);
Drawable drawable = imageButton.getBackground();
drawable.setColorFilter(0xff999999, PorterDuff.Mode.MULTIPLY);
The shape is still white...
Edit:
Even when i try
Drawable drawable = mContext.getDrawable(R.drawable.round_color);
ColorFilter filter = new LightingColorFilter(Color.BLACK, Color.BLACK);
if (drawable != null) {
drawable.setColorFilter(filter);
}
It still doesn't work!