Android one line of code to achieve circular Avatar
design sketch
In the development of app, it is often necessary to realize the circular avatar, so how to realize it?
Do you want to clip? Do you want to override the draw function? No, it can be implemented in one line of code
Glide realizes circular image
Load is the loaded image, and error is the image loaded in case of error. Transform modifies it. We also modify it through this glidecirtransform. If you use it, replace mcontext with your own activity, and mimage is the location where the image is loaded
Preparation before use
1. Add project dependency
2. Import the glidecircletransform.java file
The code of glidecircletransform.java is as follows:
After completing these two steps, you can use that line of code to complete your own round head!
The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. At the same time, I also hope to support a lot of programming tips!