问题描述
近日,笔者在Android上导入基于Web的应用程序。
我想要的WebView背景色的透明
Recently, I implement webbased-application on Android.I want to make webview's background color Transparent.
搜索,我发现,两行的网页视图。
Searching, i've found that two lines for Webview.
newWebView.setBackgroundColor(0x00000000);
newWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
它适用于Android版本4.0〜4.3,但4.4不起作用奇巧。
It works for Android version 4.0~4.3, but does not work for 4.4 KITKAT.
我只是白色背景。
Addtionally,当我设置背景色,黑色,如下图所示:
I got just white-background.Addtionally, when i set background color, black, shown below :
newWebView.setBackgroundColor(Color.BLACK);
我也看到了白色背景。
有没有人知道该如何解决?
Also I saw white-background.Is there anybody knows the solution ?
推荐答案
这可能会帮助你。
webView.setBackgroundColor(0x00000000);
if (Build.VERSION.SDK_INT >= 11) webView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
this.wv.setWebViewClient(new WebViewClient()
{
@Override
public void onPageFinished(WebView view, String url)
{
view.setBackgroundColor(0x00000000);
if (Build.VERSION.SDK_INT >= 11) view.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
}
});
来源:<一个href=\"http://$p$pmius.net/blog/andoid/118-android-webview-transparent-background-for-android-2-3-and-4-x.html\" rel=\"nofollow\">http://$p$pmius.net/blog/andoid/118-android-webview-transparent-background-for-android-2-3-and-4-x.html
这篇关于如何使Android网页视图背景透明的奇巧(4.4)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!