java – Picture by ImageButton shape

Question:

I made an ImageButton with rounded corners, but the picture on it is still square. How do I make the picture the same shape as the ImageButton , be it a rounded square or a circle?

Answer:

Look towards the masks. In my opinion, the easiest way to implement the desired behavior is to create a class inherited from ImageView and in it override the dispatchDraw method in which to apply a mask. This is where this topic was raised.

Scroll to Top