美文网首页Android开发笔记
Android中WebView闪烁问题

Android中WebView闪烁问题

作者: 道阻且长_行则将至 | 来源:发表于2019-06-21 15:14 被阅读0次

Android中WebView闪烁问题

解决方法

webView默认隐藏然后在onPageFinished回调中显示

public void onPageFinished(WebView view, String url)
{//页面加载完成

    mBinding.webviewTrans.setBackgroundColor(Color.TRANSPARENT);
    mBinding.webviewTrans.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
    mBinding.webviewTrans.setVisibility(View.VISIBLE);
}

在loadUrl之前 设置webView的背景为透明的

    mBinding.webviewTrans.setBackgroundColor(Color.argb(1, 0, 0, 0));
    mBinding.webviewTrans.loadUrl(webUrl);

agentweb在webview的基础上包了一层view 因此需要设置webview以及它的父级view才能实现透明,否则默认是白色背景

mAgentWeb.getWebCreator().getWebView().setBackgroundColor(0x00000000);
mAgentWeb.getWebCreator().getWebParentLayout().setBackgroundColor(0x00000000);

相关文章

网友评论

    本文标题:Android中WebView闪烁问题

    本文链接:https://www.haomeiwen.com/subject/owvnbqtx.html