I am using a normal image view to display images from my server, now I want to show gif animations but have no idea how to do it, can you please help me?
Asked
Active
Viewed 2,415 times
2
-
Refer this link http://stackoverflow.com/questions/3660209/display-animated-gif – Hari_krish4 Jul 06 '16 at 14:53
2 Answers
4
I use this library in my project https://github.com/koral--/android-gif-drawable
It works perfectly in RecyclerView.
Using library is very simple, just add
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.16'
to your build.gradle file and use it in you layout like this
<pl.droidsonroids.gif.GifImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/src_anim"
android:background="@drawable/bg_anim"
/>
Or you can use it from code like this:
GifDrawable gifFromPath = new GifDrawable( "/path/anim.gif" );

Dmitriy Puchkov
- 1,530
- 17
- 41
2
You can use a library called Glide, check this link https://github.com/bumptech/glide
Add the dependency to your build.gradle
dependencies {
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:support-v4:19.1.0'
}
To show the gif in your ImageView use this sample:
ImageView imageView = (ImageView) findViewById(R.id.imageView);
Glide.with(context)
.load(imageUrl)
.asGif()
.crossFade()
.into(imageView);

Ismael Di Vita
- 1,806
- 1
- 20
- 35
-
@user3693698 then you should get used to it, since otherwise you will need to code everything yourself. – user1940676 Jul 28 '18 at 09:16