您的位置:首页 > 移动开发

android webView加载gif图片并且居中显示

2013-09-06 10:14 711 查看
开源的gifView在我使用的时候 内存不释放,容易引起内存泄露,最后不得不使用webView

gif图片放到asset文件夹下边,

WebViewgf1=(WebView) findViewById(R.id.gif1);

gf1.loadDataWithBaseURL(null,"<center><imgsrc='file:///android_asset/gif2.gif'></center>","text/html","utf-8", null);

webView在RelativeLayout中居中显示,如果RelativeLayout设置android:gravity="center" 仍然没有效果,在webView中设置

android:layout_centerVertical="true"

android:layout_centerHorizontal="true"

android:layout_centerInParent="true"

ondestory()方法里边

gf1.loadUrl("about:blank");

gf1.stopLoading();

gf1= null;

回收
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: