Android WebView呈现空白/白色,视图不更新css更改或HTML更改,动画是不停的 [英] Android WebView renders blank/white, view doesn't update on css changes or HTML changes, animations are choppy

查看:1011
本文介绍了Android WebView呈现空白/白色,视图不更新css更改或HTML更改,动画是不停的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我做一个css类更改,这些更改并不总是出现。这似乎发生在我有一个触摸事件,添加类似一个向下类名称到按钮。该按钮不更新,页面上也没有任何其他内容。这是非常不稳定的时候工作。我也注意到,有时我的元素显示白色,没有内容或任何东西。这是非常令人沮丧的!

When ever I make a css class change, the changes don't always appear. This appears to happen when I have a touch event that adds something like a down class name to a button. The button doesn't update, and neither does anything else on the page. It's very inconstant in when it works. I've also noticed that sometimes my elements appear white with no content or anything. This is very frustrating!

推荐答案

我实现了kyle的解决方案,它解决了问题。我注意到了一个巨大的电池消耗在Android 4.0.4当应用程序打开。在更改后,我有用户抱怨swiftKey键盘不再与我的应用程序工作。

I implemented kyle's solution and it solved the problem. Howewer I noticed a huge battery drain on android 4.0.4 when the app was open. Also after the change I had users complaining that the swiftKey keyboard was not working with my app anymore.

我的应用程序中的每一个更改都是由用户操作触发的,所以我来了在触发事件后只触发invalidate()的修改版本:

Every change in my app are triggered by a user action so I came up with a modified version that only trigger invalidate() after a touchEvent:

    Handler handler = new Handler();
    public boolean onTouchEvent (MotionEvent event){
        super.onTouchEvent(event);
        handler.postDelayed(triggerInvalidate, 60);
            handler.postDelayed(triggerInvalidate, 300);
        return true;
    }

    private Runnable triggerInvalidate=new Runnable(){
        public void run(){
            invalidate();
        }
    };

没有使用Java编程,所以可能有更好的解决方案。

Never did any programming with Java so there might be a better solution to do this.

这篇关于Android WebView呈现空白/白色,视图不更新css更改或HTML更改,动画是不停的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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