3

I use a webview to load a HTML5 animation. As default webview is a small banner and expand when click it, The HTML5 page also change large.

I expect the progress very smooth, but a white background always shows on the bottom. And the HTML5 page show part by part. It seems like WebView draw the HTML5 page delay and slowly.

I googled much time but didn't find solution. I tried to turn on or turn off the hardware acclerate but it doesn't work.

I use animation to expand, this is code of animation:

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;
    }
}

expand progress

sabadow
  • 5,095
  • 3
  • 34
  • 51
wayne_bai
  • 1,218
  • 4
  • 14
  • 23

0 Answers0