首页 > 移动平台 > 详细

安卓 使用webview加载gif格式动画

时间:2015-10-20 19:17:51      阅读:656      评论:0      收藏:0      [点我收藏+]

这一篇写使用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);

 

安卓 使用webview加载gif格式动画

原文:http://www.cnblogs.com/1406675711blog/p/4895570.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!