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

查看:36
本文介绍了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.

我的应用程序中的每个更改都是由用户操作触发的,所以我想出了一个修改版本,它只在 touchEvent 之后触发 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天全站免登陆