How can I apply an alpha mask to an Android drawable? -


in application, need change background color of button in response events. works fine setting creating drawable, setting paint , using drawable button background:

    shapedrawable drawable = new shapedrawable(roundrectshape);     drawable.getpaint().setcolor(color);     b.setbackground(drawable); 

now, want overlay alpha mask onto drawable, creating "striped" button. here's how should blue , black button (assuming white background color, these sections should 100% transparent):

enter image description here

i made alpha mask in inkscape, , imported vector asset. might need convert bitmap of sorts, i'm not sure.

i've read bunch of articles , questions mentioning porterduff matrices apply, haven't been able translate these solving current problem.

anyone know how this?


here's visualization, making things clearer. background color of parent view of button pale pink here, , button border outlined in red (but should invisible in end product):

enter image description here

//this help.

imageview img = (imageview) findviewbyid(r.drawable.yourimage);  img.setalpha(100); 

//transparent between 0 , 255; //if want use bitmap

bitmap b = bitmapfactory.decoderesources(getresources(), r.drawable.yourimage);  img.setimagebitmap(b);  img.setalpha(100); 

Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -