I can load a gif image url, but not able to load with Glide using this code.
Glide.with(context)
.load("gif imageurl")
.asGif()
.crossFade()
.into(imageview);
How to load a gif image from server using Glide?
You can try this approach:
Glide.with(context)
.load(R.raw.sample_gif)
.into(new GlideDrawableImageViewTarget(yourImageView))
or so, try to move the call of the method asGif before the loading
Glide.with(context)
.asGif()
.load("gif image url")
.crossFade()
.into(imageview);
You can try this below code:
ImageView gif = (ImageView) findViewById(R.id.gif);
Glide.with(this)
.asGif()
.load("gif image url")
.into(gif);
You can try on this way it's work fine.
ImageView im_gif = (ImageView) findViewById(R.id.im_gif);
Glide.with(this).asGif().load(R.raw.gif_logo).into(im_gif);
You can add your gif image file to resource/raw folder.and set that name into load method.
Related
Is it possible to show GIF and also JPG image on the same adapter using Glide? If it is possible, then how code looks like in Glide?
You can do like this
String str = "image or gif url";
if (str.contains(".gif")){
Glide.with(this)
.asGif()
.load(str)
.into(imgeview);
}else{
Glide
.with(this)
.load(str)
.centerCrop()
.into(myImageView);
}
Thanks in advance,
I am trying to show a gif image in my imageView . Gif image exists locally in my device.
ImageView imageView = (ImageView) findViewById(R.id.img);
File file = new File(Environment
.getExternalStorageDirectory().toString(), "sample.gif");
Uri uri = Uri.fromFile(file);
Glide.with(getApplicationContext()).load(uri).into(imageView);
The file path is correct, still not able to see the gif loading.
If you are using gif image from raw folder than please use below code
ImageView imageView = (ImageView) findViewById(R.id.imageView);
GlideDrawableImageViewTarget imageViewTarget = new GlideDrawableImageViewTarget(imageView);
Glide.with(this).load(R.raw.sample_gif).into(imageViewTarget);
If you are using any other url for loading gif image.
Glide.with(context)
.load(imageUrl)
.asGif()
.placeholder(R.drawable.loading2)
.crossFade()
.into(imageView);
Keep in mind that just using load() will load either a GIF or a Bitmap depending on the type of the data. Unless you want your load to fail if the given url is not a gif, you don't need to specify asGif()..
Hope this help u...inform me if u need any other help
I am using glide library for loading my images , i am showing entire images , i want to show thumbnail image. How to do it?
Glide.with(context)
.load(resized)
.centerCrop()
.placeholder(R.drawable.default_review)
.crossFade().fitCenter()
.into(triviaImage);
I have tried scaleType:fitXY and scaleType:centerCrop nothing worked.
please see image
You should have to use override(width, height) as shown here:
Glide.with(context)
.load(resized)
.asBitmap()
.override(400, 400) // smaller the size, lower the quality of Image
.centerCrop()
.error(R.drawable.image_error_placeholder)
.into(triviaImage);
try this,
Glide
.with( context )
.load( resized )
.thumbnail( 0.1f )
.into( triviaImage);
I fix my problem by this -
Glide.with(context)
.load(myImageUrl)
/*Here "myImageUrl" is the original image url*/
.thumbnail(Glide.with(context).load(myThumbImageUrl).centerCrop())
/*Here "myThumbImageUrl" is the thumb image url*/
.into(view);
I want to keep all the transformation, stoke and animations identical and was thinking if we can pass resource ID or asset name in Glide to load it locally?
For resource ids, you can use:
Glide.with(fragment)
.load(R.drawable.resource_id)
.into(imageView);
For assets, you can construct an asset uri:
Glide.with(fragment)
.load(Uri.parse("file:///android_asset/<assetName>"))
.into(imageView);
Glide
.with(context)
.load(uri)
.asBitmap()
.placeholder(R.drawable.yourimage)
.error(R.drawable.yourimage)
.into(yourview);
Apart from the above answer if the image URL return null you can load default image into the view as like above.
It works when using .asBitmap()
String pathUri="file:///android_asset/img/flower.jpg";
Glide.with(context).asBitmap().load(Uri.parse(pathUri)).into(holder.imgView_post);
I have tried to use Glide to load an Captcha image into a ImageView. The first time loading is fine. However, when I reload the Captcha image into the same ImageView, the ImageView does not refresh to new image. Does anyone have idea how to solve this issue?
String url = "https://captcha_path";
ImageView imgView = (ImageView)getActivity().findViewById(R.id.imgView);
Glide.with(getActivity()).load(url).asBitmap().diskCacheStrategy(DiskCacheStrategy.NONE).into(imgView);
You can always use Glide.clear() and then call Glide.with(...).load() again. If your url doesn't change when the image changes, you may also need to add .skipMemoryCache(true) to your load call. For more control, check out the .signature() API. You can always do something like:
Glide.with(fragment)
.load(url)
.signature(new StringSignature(UUID.randomUUID().toString()))
.into(imgView);
Glide.with(fragment)
.load(url)
.signature(new StringSignature(UUID.randomUUID().toString()))
.into(imgView);
Replace StringSignature with ObjectKey (for Glide v4)
Glide.with(fragment)
.load(url)
.signature(new ObjectKey(UUID.randomUUID().toString()))
.into(imgView);