android - Change shape color -
i have 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 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 best way change solid color of shape?
imagebutton imagebutton = (imagebutton) ((activity) mcontext).findviewbyid(r.id.color_picker_button); drawable drawable = imagebutton.getbackground(); drawable.setcolorfilter(0xff999999, porterduff.mode.multiply);
the shape still white...
edit:
even when 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!
this how it, change code accordingly.
gradientdrawable bgshape = (gradientdrawable) getchildat(0).getbackground(); bgshape.setcolor();
Comments
Post a Comment