2
webview.loadUrl("http://example.com/image.gif");

loads an animated gif

webview.loadData("<img src='http://example.com/image.gif'/>","text/html", "UTF-8");

loads a static image

webview.loadUrl("http://example.com/gif.html");

loads a page where every gif is not animated.

i've tested this on the emulator and on my galaxy tab 10.1 running 4.0.4. I've seen some apps that load a webview with a page and they have animated gifs soo i must be missing something.

webview.getSettings().setJavaScriptEnabled(true);

doesn't change anything and i've tried http://code.google.com/p/slidetypekeyboard/source/browse/trunk/assets/index.html but it wont animate the gif either

what i'm asking : how to enable gif animation with .loadData() ? To expand, i want

webview.loadData("<center><img src='http://example.com/image.gif'/><center>","text/html", "UTF-8");

to display the animated gif.

4

1 回答 1

1

I had the same problem. This answer helps me. It has a different theme, but main trick is that

"For some reason loadDataWithBaseURL and loadData functions have completely different implementation."

Try this:

webview.loadDataWithBaseURL(null, "<center><img src='http://example.com/image.gif'/><center>", "text/html", "utf-8", null);
于 2013-05-07T06:48:40.723 回答