How to show Gif image in Glide on Android - android

I want show Gif image in Glide library. I write below codes but when show my gif, show very very slow motion . i want show gif normally bit rate not slow motion.
ImageView test = (ImageView) findViewById(R.id.testImageGif);
GlideDrawableImageViewTarget imageViewTarget = new GlideDrawableImageViewTarget(test);
Glide.with(this)
.load(R.drawable.login_image)
.into(imageViewTarget);
how can it?

try this
ImageView test = (ImageView) findViewById(R.id.testImageGif);
Glide
.with(this)
.load(R.drawable.login_image)
.asGif()
.into(test);

as #SachinThampan said Here
Xml:
<ImageView
android:id="#+id/title_gif"
android:layout_width="#dimen/gif_width"
android:layout_height="#dimen/gif_height"
/>
Java:
ImageView imageView = (ImageView) findViewById(R.id.title_gif);
Glide.with(this).asGif().load(R.raw.animated_gif).into(imageView);
In build.gradle:
implementation 'com.github.bumptech.glide:glide:4.0.0'

Related

Image not properly loaded in PolygonImageView using Glide

I am trying to load the image in polygon ImageView using glide library here is the code
GlideApp.with(Activity.this)
.load(path)
.placeholder(R.drawable.user_avatar)
.into(polygonImageView);
When i using this code result is in below image (the image is cut from right and bottom)
But i want this as result
For Polygon ImageView using third party library Click Here to Check Library
Any Help from you will be appreciated.Thanks
I am Refered That PolyGon Imageview Library But Issue was not There.
Just Use This Code It ll be Works Like a Charm
RequestOptions options = new RequestOptions();
options.centerCrop();
Glide.with(this)
.load("your URL")
.apply(options)
.into((ImageView) findViewById(R.id.imageview));

How to load image to card view from firebase?

I am successfully upload my image to firebase but how can show every image in the firm of card view and make it clickable to open activity
You can place an ImageView inside cardview and use Glide library to fetch the image from firebase. Below is the code snippet
String imgUrl = "url to image in firebase";
ImageView iView = (ImageView) view.findViewById(R.id.imageView);
Glide.with(mContext).load(imgUrl)
.thumbnail(0.5f)
.crossFade()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(iView);
There might be other ways but i used this and its fast and simple. Hope it will help you. Thank you.

display image contained in a link on an imageview

I am trying to display the image in this link: https://dl.dropboxusercontent.com/u/11469423/m6.jpg
in an imageview. i referred to some posts and i did it the following way:
URL url = new URL("https://dl.dropboxusercontent.com/u/11469423/m6.jpg");
Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
mIVPic.setImageBitmap(bmp);
but at runtime, the imageview is displayng nothing.
please let me know why the image in the link is not getting displayed on the imageview and how to do it
Take a look at the picasso library
Then you can do things like
Picasso.with(context)
.load("http://i.imgur.com/DvpvklR.png")
.into(imageView);

Glide not resize image correctly on Android

I use the bumptech android-glide library to show a bottom banner image on my android application on two different activities. The problem is the main Activity load the image and shows at full size instead of showing centered.
I override the size in both definitions but I can't resize the image on the first Activity. I think the second one is using the cached image loaded by glide but I'm not really sure.
Code of image declared on both layout Activities
<ImageView
android:id="#+id/main_sponsor_banner"
android:layout_width="match_parent"
android:layout_height="50dp"
android:scaleType="centerInside"
android:src="#drawable/default_main_sponsor"/>
Code of glide library on both Activities
ImageView sponsorImage = (ImageView) findViewById(R.id.main_sponsor_banner);
String sponsor_url = "https://static.prosperwalk.com/prosperwalk/organizations/0E79176F-75EB-4096-A1F2-35B886AE24E0/members/FF72A93A-DAB2-4127-ABF2-9417F1F128B7/4D1D86BF-E2A2-4C52-8485-921EDCB7CC99.png";
Glide.with(this)
.load(sponsor_url)
.thumbnail(0.5f)
.crossFade()
.placeholder(R.drawable.default_main_sponsor)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(sponsorImage);
Thanks and any help is appreciated.
Try to use DiskCacheStrategy.SOURCE

How to load GIF image from drawable folder into ImageView using glide?

I have to show load GIF image from drawable to ImageView using glide.I have tried with following.
Glide.with(LoginActivity.this)
.load(getResources().getDrawable(R.drawable.bg_gif)).asGif()
.crossFade()
.into(relativeLayout);
But isn't seem working and it's working when I'm place image in raw folder.but the problem is I have to use different dimension images.
Any help would be greatly appreciated.
You can try to use Ion it works fine for me.
Ion
Using Ion
Ion.with(imgView)
.error(R.drawable.default_image)
.animateGif(AnimateGifMode.ANIMATE)
.load("file:///android_asset/animated.gif");
Using Glide
ImageView imageView = (ImageView) findViewById(R.id.imageView);
GlideDrawableImageViewTarget imageViewTarget = new GlideDrawableImageViewTarget(imageView);
Glide.with(this).load(R.raw.sample_gif).into(imageViewTarget);
Another Approach
For Glide 3.0 you need to set asGif() earlier:
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()
Just pass the resource id directly to load():
Glide.with(LoginActivity.this)
.load(R.drawable.bg_gif)
.asGif() // you may not need this
.crossFade()
.into(relativeLayout);
Steps to load Gif images from drawable
You need to move your Gif image tores/raw folder of your project
(
if your project don't have raw folder in resource directly then simply make one and put your gif in it )
and then you can simply load your gif with just one line of code
Glide.with(this)
.load(R.raw.splash)
.into(new GlideDrawableImageViewTarget(
(ImageView) findViewById(R.id.image)));
Place your Gif in the "raw" folder and use
GlideDrawableImageViewTarget imageViewTarget = new GlideDrawableImageViewTarget(imageView);
Glide.with(this).load(R.raw.test).into(imageViewTarget);
For Glide 4
GlideApp.with(this)
.load(R.raw.gif_file)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.into(imageView);

Categories

Resources