Ali P7 mobile Internet architect, Advanced Video (Daily update) free Learning please click: https://space.bilibili.com/474380680
This article will elaborate pictures to load the selection frame by using Glide:
First, add dependencies
After the addition of network access permissions
A common approach
1, Load picture to imageView
2, various forms of image loading to ImageView
3, FIG loaded with placeholder
Figure placeholder for the purpose at the time of the purpose of the picture has not been loaded out, in advance of a picture displayed to the user;
4, failed to load placed placeholder
5, load the specified format images - designated as a still picture
6, load dynamic picture
7, load the specified size image
8, close the frame memory caching mechanism
9, turn off the hard disk cache
10, when the present token solutions cited url -> GlideUrl rewriting method Glide
Then loadable Photo:
11, the image is loaded into Glide using different controls or use a different load
(1), examples of pictures to get
(2), the image is loaded into any position
12, Glide achieve preload
Remember: In diskCacheStrategy () method must set the parameters as: "DiskCacheStrategy.SOURCE", or it may preload fail, resulting in the display when the picture needs to be reloaded.
13, Glide achieve download images
using downloadOnly(int width, int height)
or downloadOnly(Y target)
methods alternative into(view)
methods.
(1), there are two parameters of downloadOnly(int width, int height)
the method indicates that the specified download size for downloading in the sub-thread;
(2), a parameter of downloadOnly(Y target)
a method for download in the main thread
(3), target.get()
the method can obtain the download file path ;
Use of downloaded pictures mode
Note: Parameter diskCacheStrategy () method be DiskCacheStrategy.SOURCE
or DiskCacheStrategy.ALL
it may cause the picture to load the control, the need to reload.
13, listening state Glide loaded
(1), onException()
the method represents a load failure, onResourceReady()
completes the loading;
(2), each method has a return value boolean, represents untreated to false, true represent processing.
14, Glide graphics transformation function
(1), disable the graphical conversion function
When this method is a global, leading the rest of the picture can not be graphically transformed.
Modification method
By setting the size of the override () method
(2), simple graphics transformation
By centerCrop()
the method according to the original and full of full-screen aspect ratio fitCenter()
method for the central area of the original image cropping the picture settings.
(3), override()
the method and centerCrop()
the method with the use of
(4), complex image transformation
firstly need to introduce a third party frameworks .
Second, some examples:
Picture blur
Black and white picture of
Multiple properties simultaneously
There are more fun properties, please see the official website of the frame: https://github.com/wasabeef/glide-transformations
Original link: https://www.jianshu.com/p/791ee473a89b
Ali P7 mobile Internet architect, Advanced Video (updated daily) is free to learn, please click: https://space.bilibili.com/474380680