jaesanx
jaesanx

Reputation: 205

Android how to set transparency to custom part of ImageView

I would like to set a custom part of an image view to be transparent. However, the partial view inside does not have to be a rectangle. It could be parallelogram, triangle, etc... I know I can retrieve the corners of the shape that I want to set to transparent, I just don't know what to do with those inputs.

Any help is appreciated!

Upvotes: 0

Views: 557

Answers (2)

Kostya Khuta
Kostya Khuta

Reputation: 1856

Try this imageView.setBackgroundColor(Color.TRANSPARENT);

Upvotes: 0

Matt Clark
Matt Clark

Reputation: 28599

You will have to manually manipulate a bitmap that you set to the image view.

Bitmap someBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.someimage);
bmp.setPixel(x,y,Color.TRANSPARENT);
someImageView.setBitmap(someBitmap);

Code not tested.

Upvotes: 1

Related Questions