Android设置WebView背景透明
2014-06-23 13:50
295 查看
Android4.0环境下WebView背景一直都是白色的,和App的整体风格不一致,所以需要把背景设为透明,本来以为非常简单的一个background属性设为透明就好了,可事情并没有这么简单,经过一番周折最后终于搞定,在这里记录下来。
首先检查配置文件里application设置android:hardwareAccelerated=”false”,自己尝试后必须这样设置才行;
在loadUrl后设置mWebView.setBackgroundColor(0);
检查xml布局文件里的WebView的父层布局,也要设置背景为透明的;(之前也因为这个问题没发现,绕了很大一个圈)
网上的解决方案
android:layerType="software"(没效果) mWebView.setBackgroundColor(0);(没效果) mWebView.setBackgroundDrawable(R.drawable.main_bg);(没效果)
总结方法
首先检查配置文件里application设置android:hardwareAccelerated=”false”,自己尝试后必须这样设置才行;在loadUrl后设置mWebView.setBackgroundColor(0);
检查xml布局文件里的WebView的父层布局,也要设置背景为透明的;(之前也因为这个问题没发现,绕了很大一个圈)
相关文章推荐
- android webview 4.0设置背景透明
- Android webview背景设置为透明无效
- Android webview设置透明背景
- Android webview背景设置为透明无效 拖动时背景闪烁黑色
- android开发(36) Android WebView背景设置为透明
- Android webview背景设置为透明无效
- Android webview 设置背景透明色
- Android webview背景设置为透明无效 拖动时背景闪烁黑色
- Android webview背景设置为透明无效
- android webview 设置背景透明色
- Android webview背景设置为透明无效
- android开发(36) Android WebView背景设置为透明
- Android webview背景设置为透明无效 拖动时背景闪烁黑色
- android webview 设置背景透明色
- Android webview背景设置为透明无效 拖动时背景闪烁黑色
- android设置WebView背景透明
- Android之webview背景设置为透明无效
- Android WebView设置背景透明
- Android SufaceView 背景设置透明
- WebView背景无法透明的设置方法