Tutorial by Examples

From the official documentation: With Gradle: repositories { mavenCentral() // jcenter() works as well because it pulls from Maven Central } dependencies { compile 'com.github.bumptech.glide:glide:4.0.0' compile 'com.android.support:support-v4:25.3.1' annotationProcessor 'com.githu...
ImageView To load an image from a specified URL, Uri, resource id, or any other model into an ImageView: ImageView imageView = (ImageView) findViewById(R.id.imageView); String yourUrl = "http://www.yoururl.com/image.png"; Glide.with(context) .load(yourUrl) .into(imageView);...
Create a circle image with glide. public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { ret...
Glide includes two default transformations, fit center and center crop. Fit center: Glide.with(context) .load(yourUrl) .fitCenter() .into(yourView); Fit center performs the same transformation as Android's ScaleType.FIT_CENTER. Center crop: Glide.with(context) .load(yourUr...
First make utility class or use this method in class needed public class UIUtils { public static BitmapImageViewTarget getRoundedImageTarget(@NonNull final Context context, @NonNull final ImageView imageView, final float radius) { retur...
To preload remote images and ensure that the image is only downloaded once: Glide.with(context) .load(yourUrl) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .preload(); Then: Glide.with(context) .load(yourUrl) .diskCacheStrategy(DiskCacheStrategy.SOURCE) // ALL works her...
If you want to add a Drawable be shown during the load, you can add a placeholder: Glide.with(context) .load(yourUrl) .placeholder(R.drawable.placeholder) .into(imageView); If you want a Drawable to be shown if the load fails for any reason: Glide.with(context) .load(yourUrl...
Create a custom BitmapImageViewTarget to load the image into: public class CircularBitmapImageViewTarget extends BitmapImageViewTarget { private Context context; private ImageView imageView; public CircularBitmapImageViewTarget(Context context, ImageView imageView) { ...
Glide .with(context) .load(currentUrl) .into(new BitmapImageViewTarget(profilePicture) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.g...

Page 1 of 1