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 library. project plaid by nick butcher shows how you can show gifs.https://github.com/nickbutcher/plaid – Raghunandan Jan 02 '16 at 05:24
-
Refers these links for that http://stackoverflow.com/questions/3660209/display-animated-gif And another one id that http://droid-blog.net/2011/10/14/tutorial-how-to-use-animated-gifs-in-android-part-1/ – Ravindra Kushwaha Jan 02 '16 at 05:26
-
I tried glide also but its not working. – user3606902 Jan 02 '16 at 05:27
-
try gifview lib: https://github.com/felipecsl/GifImageView – kiturk3 Jan 02 '16 at 05:28
-
Ok let me try all the above links. Hope one should work properly. – user3606902 Jan 02 '16 at 05:30
-
try it using videoView – Abhishek Jan 02 '16 at 05:33
4 Answers
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.

- 14,977
- 11
- 54
- 87
-
-
@user3606902, You can use `WebView` instead: http://stackoverflow.com/a/21018730/3922207 – Anggrayudi H Jan 02 '16 at 06:51
-
2It is taking time because first it gets downloaded in the cache. If you want quick output, pack it in your apk in assets folder and access it from there. – Dhrumil Shah - dhuma1981 Jan 02 '16 at 06:55
The easy way to display animated GIF directly from URL to your app layout is to use WebView class.
Step 1: In your layout XML
<WebView
android:id="@+id/webView"
android:layout_width="50dp"
android:layout_height="50dp"
/>
Step 2: In your Activity
WebView wb;
wb = (WebView) findViewById(R.id.webView);
wb.loadUrl("https://.......);
Step 3: In your Manifest.XML make Internet permission
<uses-permission android:name="android.permission.INTERNET" />
Step 4: In case you want to make your GIF background transparent and make GIF fit to your Layout
wb.setBackgroundColor(Color.TRANSPARENT);
wb.getSettings().setLoadWithOverviewMode(true);
wb.getSettings().setUseWideViewPort(true);

- 159
- 1
- 6
Hello everyone how asking about showing gif from url in android studio just follow my lead:
First we are about to use glide library so we need to implement the dependencie
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
second thing to do after sync your gradle is go the your xml and create a new imageView
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/image_id"
android:layout_centerInParent="true"/>
and finally go to your mainActivity or activity that realated to this xml : first declare ImageView and find the id in onCreate like this:
public ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
imageView=findViewById(R.id.image_id);
and the last thing is using glide library to show the gif yes of course from Url :
Glide.with(this).load("https://media.giphy.com/media/xT5LMJmXRmrn3ft04w/giphy.gif").into(imageView);
that's it but if you want to use the gif from your drawable use this line instead :
Glide.with(this).load(R.drawable.imageGif).into(imageView);
This is the Glide library here: https://github.com/bumptech/glide

- 504
- 4
- 7
You can set imageview as like :
<com.example.androidgif.GifView
android:id="@+id/gifview"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Following this tutorial you can do it :
http://android-er.blogspot.de/2014/03/load-animated-gif-from-internet.html

- 93
- 1
- 2
- 10