Android custom view to achieve circular cut effect

Use the custom view to achieve the effect of circular ImageView. The details are as follows

At present, the circular border needs to be adjusted. There is a problem here

Realization idea

Use a paint to set the resulting bitmap as the shader of the paint. After setting, use the matrix to adjust the picture to the center, use rectf to constrain the border, and finally complete the painting

Initialize paint and set shader

Get drawable

Calculate margin

Adjust the matrix to prevent only the edges and corners of the picture from being displayed

onDraw

Complete code

There are still some problems. They will be updated in time after they are solved.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>