机器人的WebView后期渲染 [英] Android webview late rendering

查看:127
本文介绍了机器人的WebView后期渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一个应用程序大多是在JS(Mootools的)和HTML被加载到的WebView 在我的应用程序。

这是它显示或通过添加或删除 nodisplay 类隐藏在页面的某些部分(要素)只是一个HTML文件:

  .nodisplay {显示:无}
功能showPage1()
{
     $$(网页。)addClass('nodisplay')。
     $(第1页)removeClass移除('nodisplay')。
}
 

在安卓4(XPERIA弧和GALAXY NOTE 2)我看到一个奇怪的后期渲染,但我不知道老版本的行为。当我隐藏的元素,表现出一个又一个,它似乎正确的在第一,但滚动的旧元素的某些部分中出现毫秒,并立即消失。这就像渲染不可见区域被推迟到图纸的时刻。

和也有时它只是隐藏和显示过程中做杂闪烁。

在Chrome浏览器在PC上也没有任何问题。即使在AVD它的工作原理很锋利,没有任何闪烁。

我不知道这是否是Android的一个问题,如果有什么办法来克服它?!

我试过安卓hardwareAccelerated =假|真正的,没有任何影响。 并且还 ws.enableSmoothTransition()不解决这个问题也没有。

解决方案

阿杰的回答给了我的东西,我用在另一个项目,所以我可以使的WebView 背景透明的提示。到现在我还不知道code关闭硬件加速。我测试了code,和平在这个项目中,也没有晚渲染了。虽然滚动页面是不是一帆风顺的,但之前它比后期渲染更好。

这是在code来解决这一切的:

 如果(Build.VERSION.SDK_INT> = 11)wv.setLayerType(WebView.LAYER_TYPE_SOFTWARE,NULL);
 

顺便说一句,这就像定义安卓hardwareAccelerated =假不影响的WebView <! / P>

I've written an app mostly in JS (Mootools) and HTML which is loaded into webview in my app.

It's just one html file which show or hide parts (elements) of the page by adding or removing a nodisplay class:

.nodisplay {display:none}
function showPage1()
{
     $$('.pages').addClass('nodisplay');
     $('page1').removeClass('nodisplay');
}

In android 4 (xperia arc and galaxy note 2) I see a strange late rendering, but I don't know how older versions behave. when I hide an element and show another one, it appears correct at first but during scrolling some parts of the old elements appears for milliseconds and disappears immediately. It's like the render of non visible area is postponed to drawing moment.

And also sometime it just do odd blinks during hiding and showing.

In chrome on PC it don't have any problem. Even in the AVD it works very sharp without any blinks.

I don't know if it's a problem of android and if there is any way to overcome it?!

I tried android:hardwareAccelerated="false"|"true" , no effect. and also ws.enableSmoothTransition() which doesn't solve the problem neither.

解决方案

Ajay answer gave me a hint of something I used in another project so I could make WebView background transparent. Till now I didn't know that code turns off hardware acceleration. I tested that peace of code in this project and there is no late rendering anymore. although scrolling the page is not as smooth as before but it's better than late rendering.

This is the code to fix all of this:

if (Build.VERSION.SDK_INT >= 11) wv.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);

By the way, it's like defining android:hardwareAccelerated="false" doesn't affect webview!

这篇关于机器人的WebView后期渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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