I want to play animated gif from url in android app like imgur app. Imagur is superb and very fast. I am loading gif with webview but its not up to the mark.
You can use Glide to play gif on ImageView
. So, let's add it to your app's gradle:
repositories {
mavenCentral()
}
dependencies {
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:support-v4:23.1.1'
}
Then, create an ImageView
:
<ImageView
android:id="@+id/imageView"
android:contentDescription="@string/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
In your activity:
Glide
.with(context) // replace with 'this' if it's in activity
.load("http://www.google.com/.../image.gif")
.asGif()
.error(R.drawable.error_image) // show error drawable if the image is not a gif
.into(R.id.imageView);
For more information, open this post Glide — Displaying Gifs & Videos.