There are two options for loading animated gifs in an Android application. using these methods you can load animated gifs from a url.
1) Using Glide to load the animated gif within ImageView
.
String urlGif = "https://domain.com/myanimatedgif.gif";
//Agregar implementacion Glide dentro de archivo build.gradle.
ImageView imageView = (ImageView)findViewById(R.id.imageView);
Uri uri = Uri.parse(urlGif);
Glide.with(getApplicationContext()).load(uri).into(imageView);
2) Using an html to load the animated gif within WebView
.
Create an html that contains the path to the .gif file:
<html style="margin: 0;">
<body style="margin: 0;">
<img src="https://..../myimage.gif" style="width: 100%; height: 100%" />
</body>
</html>
store this .html file inside the /assets
directory:
Now load the html within WebView
in your application:
WebView webView = (WebView)findViewById(R.id.webView);
webView = (WebView) findViewById(R.id.webView);
webView.loadUrl("file:///android_asset/html/webpage_gif.html");
Here is a full example showing both options .