Android uses circleimageview to realize circular Avatar

Sometimes we use circular avatars in our applications. The following is a demonstration of using circleimageview to realize circular avatars. The following effects and codes are shown in the figure below

The implementation is also relatively simple. First, create a circleimageview package in the project to store the circleimageview class. Later, directly copy the circleimageview class to the package

Then, build another attrs XML, whose code is quite simple, defines the width and color of the circular border

Then use the circleimageview in the layout file of your application's activity

Note that you should write circleimageview The full path of circleimageview should also be specified

xmlns:app=" http://schemas.android.com/apk/res-auto "

This is based on the whole layout above

xmlns:android=" http://schemas.android.com/apk/res/android "

Yes, just change RES / Android to res auto, and then specify border_ Width and border_ Color, and then in the activity, you can directly find it by using ID

Finally, the code of the circleimageview class can be found on the Internet, but it's still posted here

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
分享
二维码
< <上一篇
下一篇>>