Share a special way for Android to set up circular pictures
Cardview and ImageView display circular rendering:
When I was just looking at the knowledge points of the custom view, I suddenly remembered that if the width and height of the cardview are equal, when the radius of the fillet set by the cardview is half of the width and height, it is not a circle?!
1. Layout documents
Framlayout inherited by cardview. The width and height are both 200dp, and the fillet radius is set to 100dp
2. Code in acity
Use glide to load pictures
Onwindowfocuschanged (Boolean hasfocus) can be used to judge whether the activity has obtained the focus. At this time, you can get the width and height of the control, which is a way to get the width and height of the control.
3. Summary
In the past, a custom circleimageview was used. If you just want a circular graph, this method can also be considered. I wonder if this method has been used. It's also very convenient to add text to the picture. I think this method is relatively simple. The above is the whole content of this article. I hope it can be helpful to your development.