Method of making round head portrait using circleimageview and cardview in Android

Round avatars are very common in our daily apps because they are more beautiful

The method of using circular pictures may be that we can directly cut the pictures into circles and then use them in the app, or use the custom view to automatically cut any pictures we set into circles.

design sketch:

The circleimageview on GitHub is used here

github: https://github.com/hdodenhof/CircleImageView

Cardview is a card view as its name implies. Cardview inherits FrameLayout, so you should pay attention to it when placing internal controls

You can set shadows, fillets, and so on

The circleimageview here can also set stroke for avatars.

Let's create a new project and select navigation drawer activity to automatically generate the initial layout.

Modify nav_ header_ Main, add rounded head

Modify the content again_ Main, add recyclerview and remember to import the package

Add item layout, cardview and import package

Next, add code in mainactivity and use our cardview

1. Add member variables and data sources

2. Create viewholder

3. Create an adapter

4. Set the adapter in the oncreate () method

The above is what Xiaobian introduced to you about the method of making circular avatars using circleimageview and cardview in Android. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

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