WebView显示gif图片
2013-12-12 10:45
211 查看
因为一些需求,需要显示gif图片,发现可以在webview上直接显示,我用的是4.0版本的
xml中的代码
<WebView
android:id="@+id/main_webview"
android:layout_marginLeft="850dip"
android:layout_marginTop="300dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
/>
activity中的代码
webview_GIF = (WebView) findViewById(R.id.main_webview);
webview_GIF.loadUrl("file:///android_asset/merryc.gif");
webview_GIF.setVisibility(View.VISIBLE);
webview_GIF.setFocusable(false);
是本地的图片资源,所以要用file:///,存在asset文件夹下面,图片名称为merryc.gif
然后程序跑起来的时候就可以直接显示了,当然,你可以自己设定什么时候显示,在哪显示
注意:webview显示是有白色的背景图片的,需要设置背景为透明色
设置背景透明:参考资料/article/8560580.html
xml中的代码
<WebView
android:id="@+id/main_webview"
android:layout_marginLeft="850dip"
android:layout_marginTop="300dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
/>
activity中的代码
webview_GIF = (WebView) findViewById(R.id.main_webview);
webview_GIF.loadUrl("file:///android_asset/merryc.gif");
webview_GIF.setVisibility(View.VISIBLE);
webview_GIF.setFocusable(false);
是本地的图片资源,所以要用file:///,存在asset文件夹下面,图片名称为merryc.gif
然后程序跑起来的时候就可以直接显示了,当然,你可以自己设定什么时候显示,在哪显示
注意:webview显示是有白色的背景图片的,需要设置背景为透明色
设置背景透明:参考资料/article/8560580.html
相关文章推荐
- android webView加载gif图片并且居中显示
- 如何让WebView显示gif格式的图片
- Android WebView加载网页不显示图片解决办法
- ImageLoader 显示图片+webView显示网页
- android https加载WebView图片不显示问题
- WebView加载网页不显示图片解决办法
- Android WebView显示不全的问题。图片不显示的问题。
- 使用WebView时的一些坑(图片拼接、不显示、shouldOverrideUrlLoading正确用法)
- Android Webview调相机拍照选择图片并显示到网页
- webview加载gif图片
- Android 5.0中使用webView 加载网页不显示图片问题
- 使用GifView在android上显示gif图片
- 图片不能显示: [cell.imageView setImageWithURL:imageUrl placeholderImage:nil options:SDWebImageLowPriority
- Android 用WebView显示工程内的图片
- webView加载 https 的网页,不显示图片.md
- Swift - 集成app启动页广告,切换rootViewController,支持LaunchImage和LaunchScreen.storyboard,支持GIF图片显示,支持视图过渡动画
- Android 环境WebView中图片自适应显示
- 解决android webview中图片不显示问题
- Android Http基础:图片下载并显示和WebView的应用
- Android在使用WebView时,图片显示出错问题。