这一篇写使用webview加载gif动画,
贴代码:
xml:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="@+id/buttons"
android:layout_marginTop="20dp"
android:gravity="center">
<WebView
android:id="@+id/webView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
这是布局中的某一个控件
----------------------------------------------------------
activity中调用:
mWebView = (WebView) findViewById(R.id.webView1);
String gifFilePath = "file:///android_asset/1.gif";//首先将一张gif格式的动图放置在assets中
mWebView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
String data = "<HTML><Div align=\"center\" margin=\"0px\"><IMG src=\"" + gifFilePath + "\" margin=\"0px\"/></Div>";//设置图片位于webview的中间位置
mWebView.loadDataWithBaseURL(gifFilePath, data, "text/html", "utf-8", null);
原文:http://www.cnblogs.com/1406675711blog/p/4895570.html