Introduction to the basic usage of glide, an Android image loading framework
brief introduction
Glide is a picture loading framework, which can load and display pictures in a simple way on the Android platform.
Add permissions to the manifest file
Load picture
http://sc.jb51.net/uploads/allimg/150709/14-150FZ94211O4.jpg
New layout file
activity_ main.xml
MainActivity.java
Just one line of code can load the picture
The glide. With() method is called to create an instance of the picture. The with method can accept parameters of type context, activity and fragment. If the call is not in the activity or fragment, you can pass in ApplicationContext.
Glide supports loading various picture resources, including network pictures, local pictures, application resources, URI objects, etc
Occupation bitmap
Exception occupied bitmap
Specify picture format
Glass supports loading GIF images, while Picasso does not support loading GIF images.
Glide will automatically determine the image format. For example, this is the URL of a GIF image:
Only static graphs are allowed to load: asbitmap
If a GIF dynamic graph is passed in, only the first frame will be displayed
Only dynamic graphs are allowed to load:. Asgif()
Specify picture size
With glide, we don't have to worry about image memory waste or even memory overflow. Because glide never directly loads the full size of the picture into memory, but how much it uses. Glide will automatically determine the size of ImageView, and then only load such large picture pixels into memory.
Of course, we can also specify the fixed size of the picture
When specifying the image size, the width and height of the ImageView should be the package content
Loading effect:
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.