Android’s method of dynamically loading glide pictures of different sizes into tangent angles and circles

Glide load dynamic picture

First, we need to rely on a githop: bumptech: glide: glide: 3.7.0 package;

Use glide to load pictures in combination with the style of the list:

1) If you are using listview, you can directly use it in the getview method of the adapter:

2) If recyclerview is used, you can use it in the onbindviewholder method of the adapter:

3) When loading a network picture, because the picture cannot be displayed in time during loading, it may be necessary to set the waiting picture through the placeholder() method:

4) When loading a picture fails, set the picture display after loading failure through the error (drawable drawable) method:

5) Zooming of pictures, centercrop() and fitcenter():

6) Show GIF animation:

7) Show local video

8) Cache policy:

9) Priority, set the loading order of pictures:

10) When you do not need to put the loaded resource directly into the ImageView, but want to obtain the bitmap object of the resource:

11) Integrated network stack (okhttp, volley):

Well, the above is how glide dynamically loads pictures. Let's start the text of this article:

demand

Glide downloads the picture and cuts it into rounded corners or circles, but the picture is big and small, and the picture cannot be changed. It's OK to cut the circle, but if you cut the rounded corners, you will find that the picture is smaller than the picture. Search "glide dynamically loads round pictures and rounded images", and many articles will appear, But none of these can solve the above problems. How can glide dynamically load pictures of different sizes, cut circular pictures and rounded pictures?

The solution is simple

Since the pictures are cut out differently due to the inconsistent size of the pictures, isn't it OK to change the pictures to the same size

To be clear, my code is also modified based on the code found by glide dynamically loading circular images and rounded images. Here is the code

build.gradle

activity_ main.xml

MainActivity

GlideCircleTransform

GlideRoundTransform

It's very simple. Use the changebitmapsize method to compress the picture to 72 * 72. In this way, the pictures are the same size, and there will be no different effects of the cut pictures

Last code (dome)

GitHub address: https://github.com/liang9/Imagedome

Local download address: http://xiazai.jb51.net/201711/yuanma/Imagedome (jb51.net).rar

summary

The above is the whole content of this article. I hope the content of this article has a certain reference value for your study or work. If you have any questions, you can leave a message. Thank you for your support for 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
分享
二维码
< <上一篇
下一篇>>