Can someone please provide a code to display GIF images in a webview ( I\'m already able to display the same using frame animation of png images) Now I want a way to display
Try this..
WebView wv = (WebView) findViewById(R.id.webView1);
wv.loadUrl("file:///android_asset/anim5.gif");
Simply call your GIF image from assets like this..
This is the best solution for GIF in Android :
Insert the following dependency to build.gradle file of your project.
dependencies {
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
}
then
The simplest way is to use GifImageView
<pl.droidsonroids.gif.GifImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/src_anim"
android:background="@drawable/bg_anim"
/>
If drawables declared by android:src and/or android:background are GIF files then they will be automatically recognized as GifDrawables and animated. If given drawable is not a GIF then mentioned Views work like plain ImageView and ImageButton.
https://github.com/koral--/android-gif-drawable
yes this is the right that gif not support in android
Another solution As TRonZ WebView supports gif , just make a WebView
and load the URL of the gif image
and you are done
Loads gif in a webview and fits it to the device screen without any HTML code...Try this code
mWebView = ((CustomWebView)mRootView.findViewById(R.id.webview));
mWebView.loadUrl("file:///android_asset/file.gif");
mWebView.getSettings().setLoadWithOverviewMode(true);
mWebView.getSettings().setUseWideViewPort(true);
Save your GIF file at Assets folder. Here "loading.gif" is the filename.
WebView webView=new WebView();
Content = webView;
webView.Source = new HtmlWebViewSource
{
Html = $"<body\"><img src=\"loading.gif\"/></body>"
};
You do not need any HTML code... Just use this line
webViewControl.LoadUrl("file://" + pathToTheGifFile);
It Works for Me.