3

我使用 webview 加载HTML5动画。由于默认的 webview 是一个小横幅,点击它会展开,HTML5 页面也会变大。

我希望进展非常顺利,但底部总是显示白色背景。HTML5页面部分显示。似乎WebView绘制HTML5页面延迟且缓慢。

我google了很多时间,但没有找到解决方案。我试图打开或关闭硬件加速,但它不起作用。

我用动画来展开,这是动画的代码:

WebView webview = (WebView)findViewById(R.id.webview);
ExpandAnimation expand = new ExpandAnimation(webview , getHeight(), 690,true);
expand.setDuration(3800);
webview.startAnimation(expand);

public class ExpandAnimation extends Animation {
    int startingHeight;
    int endingHeight;
    View view;
    boolean down;

    public ExpandAnimation(View view, int startingHeight, int endingHeight, boolean down) {
         this.view = view;
         this.startingHeight = startingHeight;
         this.endingHeight = endingHeight;
         this.down = down;
    }

    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {
         int newHeight;
         if (down) { 
            newHeight = (int) (((endingHeight-startingHeight) * interpolatedTime) + startingHeight); 
         } 
         else{ 
            newHeight = (int) (((endingHeight-startingHeight)* (1 - interpolatedTime))+startingHeight); 
         }
         view.getLayoutParams().height = newHeight;
         view.requestLayout();
    }

    @Override
    public void initialize(int width, int height, int parentWidth, int parentHeight) {
        super.initialize(width, height, parentWidth, parentHeight);
    }

    @Override
    public boolean willChangeBounds() {
        return true;
    }
}

扩大进度

4

0 回答 0