How to make animated GIFs work from Android WebView

后端 未结 5 2438
长情又很酷
长情又很酷 2021-02-19 20:24

Animated GIF images rendered by Android\'s WebView do not seem to animate. Has anyone figured out how to make them work? I\'m testing on an N1 with 2.1-u1. None of the web sett

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-19 21:10

    As a workaround, if you are using a custom WebView, you can do these 2 things together:

    • Enable Javascript for the Webview (Eg: https://github.com/LatinSuD/slidetypekeyboard/blob/master/src/com/latinsud/android/slidetypekeyboard/HelpActivity.java) Like: myWebView.getSettings().setJavaScriptEnabled(true);

    • Then use javascript to swap images (Eg: https://github.com/LatinSuD/slidetypekeyboard/blob/master/assets/index.html)

    Please note that this is not a solution for displaying GIFs, you must modify the content of the web, and convert/split GIF animations into different files (one for each frame) in any format (JPG, PNG, etc).

提交回复
热议问题