WebView wv= (WebView)findViewById(R.id.wv);
wv.setBackgroundColor(0);//setBackgroundColor(Color.TRANSPARENT)// 再不行就在xml文件中加入 //@android:color/transparent
if(Build.VERSION.SDK_INT>=11){
try {
Method method = wv.getClass().getMethod("setLayerType", new Class[] {int.class, Paint.class});
method.invoke(wv, new Object[] {1, null});
} catch (Throwable e) {
e.printStackTrace();
Log.v("", "setLayerType method not found");
}
}
String html = "<html><head>拉萨快点放假阿莱克斯的</head><body><p>sdgasgsd</p><h1>sdafgh</h1></body></html>";
wv.loadDataWithBaseURL("", html, "text/html", "utf-8", "");
android webview 4.0设置背景透明
最新推荐文章于 2025-02-26 10:08:38 发布