加载数据时的WebView重绘问题 [英] WebView redraw problem when loading data

查看:1327
本文介绍了加载数据时的WebView重绘问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到显示的问题,我使用我的应用程序中的一个web视图。

I encounter a problem of display with a webview i'm using in one of my application.

当我打电话loadData,web视图首先显示的文本,然后加载页面(标准行为)的图像。

When I call loadData, the webview first display the text and then load the images of the page (standard behaviour).

有时候,如果这些图像修改文本的位置,旧的文本位置不清零,老文和新的文字+图像显示

Sometimes, if those images modify the text position, the old text position is not cleared and both old text and new text+image is displayed

下面的是什么样子,当问题发生时就像是截图:

Here a screenshot of what it looks like when the problem occurs:

这就像web视图不正确地重新绘制它的内容。当然,一个简单的无效()不工作...

It's like the webview do not redraw correctly it's content. Of course a simple invalidate() does not work...

这经常做没有发生,但可以说一次超过20。

It do no occur often but lets say one time over 20.

code(称为外部活动的生命周期方法):

Code used to display the data (called outside Activity life cycle methods):

// Include the html headers to the content received from WS
String webtext = String.format(ConfigApp.HTML_BODY, wsdata.getText());
mWebView.setWebChromeClient(...);
mWebView.setWebViewClient(...);
mWebView.setBackgroundColor(0);
mWebView.loadDataWithBaseURL(null, webtext, "text/html", "UTF-8", null);

不知道如何解决这一问题?

Any idea how to fix this?

推荐答案

我终于找到了一种方法来解决这个问题。

I've finally found a way to fix the problem.

删除的WebView透明背景:

Remove the WebView transparent background:

String webtext = String.format(ConfigApp.HTML_BODY, wsdata.getText());
mWebView.setWebChromeClient(...);
mWebView.setWebViewClient(...);
// mWebView.setBackgroundColor(0);
mWebView.loadDataWithBaseURL(null, webtext, "text/html", "UTF-8", null);

由于我的WebView有一个空的背景是确定为我。也许这可以是恼人的其他人。

Because my WebView has a blank background it's ok for me. Maybe it can be annoying for somebody else.

有关相信这是一个的WebView错误。

For sure it's a WebView bug.

这篇关于加载数据时的WebView重绘问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆