How to play animated GIF image from url in android?

Android Developer picture Android Developer · Nov 3, 2014 · Viewed 7.8k times · Source

I am integrating giphy to my android app..

How can i play animated gif image from URL in android? Should I use ImageView, WebView, VideoView etc? For example if i want to play animation from this URL.

Answer

Rohit Sharma picture Rohit Sharma · Nov 3, 2014

Just create a html string and load that into android webview. Tested solution.

http://developer.android.com/reference/android/webkit/WebView.html#loadData(java.lang.String, java.lang.String, java.lang.String)

 String x = "<!DOCTYPE html><html><body><img src=\"http://goo.gl/uPJ9P2\" alt=\"Smileyface\" width=\"100%\" height=\"100%\"></body></html>";

 webView.loadData(x, "text/html", "utf-8");