Is there any way to show the animated gif image in any control that should also display normal jpg,png formats, The image source i will get from the server.
I have tried with the Webview but i have a problem of scrolling, The image should fit to the size of the control and also it should accept the click functionality.
My Code with webview:
Webview class:
public class GIFView extends WebView {
public static final String HTML_FORMAT = "<html><body style=\"text-align: center; vertical-align: right;background-color: transparent;\"><img src = \"%s\" /></body></html>";
public GIFView(Context context, String fileUrl) throws IOException {
super(context);
final String html = String.format(HTML_FORMAT, fileUrl);
setBackgroundColor(Color.TRANSPARENT);
loadDataWithBaseURL("", html, "text/html", "UTF-8", "");
}
}
MyActivity:
LinearLayout llProgress = (LinearLayout) findViewById(R.id.ll_progress);
GIFView gif = null;
try {
gif = new GIFView(this, "file:///android_asset/giphy.gif");
llProgress.addView(gif);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Can any one help me to get out of this issue please, Thanks in advance!