| Start |
|---|
Loading an image ImageViewTo load an image from a specified URL, Uri, resource id, or any other model into an For Uris, replace RecyclerView and ListViewIn ListView or RecyclerView, you can use exactly the same lines: If you don't want to start a load in |
| Add Glide to your project From the official documentation (opens new window): With Gradle: With Maven: Depending on your ProGuard (DexGuard) config and usage, you may also need to include the following lines in your proguard.cfg (See Glide's wiki (opens new window) for more info): |
| Glide circle transformation (Load image in a circular ImageView) Create a circle image with glide. Usage: |
| Default transformations Glide includes two default transformations, fit center and center crop. Fit center: Fit center performs the same transformation as Android's ScaleType.FIT_CENTER (opens new window). Center crop: Center crop performs the same transformation as Android's ScaleType.CENTER_CROP (opens new window). For more information, see Glide's wiki (opens new window). |
| Glide rounded corners image with custom Glide target First make utility class or use this method in class needed Loading image: Because you use asBitmap() the animations will be removed though. You can use your own animation in this place using the animate() method. Example with similar fade in to default Glide animation. Please note this animation is support library private resource - it is unrecommended to use as it can change or even be removed. Note you also need to have support library to use RoundedBitmapDrawableFactory (opens new window) |
| Placeholder and Error handling If you want to add a Drawable be shown during the load, you can add a placeholder: If you want a Drawable to be shown if the load fails for any reason: If you want a Drawable to be shown if you provide a null model (URL, Uri, file path etc): |
| Preloading images To preload remote images and ensure that the image is only downloaded once: Then: To preload local images and make sure a transformed copy is in the disk cache (and maybe the memory cache): Then: |
Handling Glide image load failed Here at |
| Load image in a circular ImageView without custom transformations Create a custom BitmapImageViewTarget to load the image into: Usage: RemarksGlide is a fast and efficient open source media management and image loading framework for Android that wraps media decoding, memory and disk caching, and resource pooling into a simple and easy to use interface. Glide supports fetching, decoding, and displaying video stills, images, and animated GIFs. Glide includes a flexible API that allows developers to plug in to almost any network stack. Glide's primary focus is on making scrolling any kind of a list of images as smooth and fast as possible, but Glide is also effective for almost any case where you need to fetch, resize, and display a remote image. Source code and further documentation is available on GitHub: https://github.com/bumptech/glide (opens new window) |
Read Article
https://develop.horje.com/learn/1434/reference