Delay in calling onDraw()

给你一囗甜甜゛ 提交于 2020-01-05 08:53:55

问题


I am writing a code which requires to update a UI multiple times within a second to display an animation .But after calling invalidate the onDraw() method gets called after around 100ms and hence the number of times the screen is repainted is reduced to only 4 or 5 times a second.

I want to know as to what exactly causes the time difference between the invalidate() command and the calling of onDraw method.

Is there any way I can reduce the delay so that my animation can be smooth?? Thanks in advance.

It is a big code I'll just post the simple format for it:

public class CustomImageView extends ImageView {

    private boolean doDoubleTap(MotionEvent e) {
        <Loop>
        tuneMatrix(matrix);//here i am changing the values for the matrix.(ie scaling and all)
        invalidate();
        System.out.println("CustomImageView.doDoubleTap():invalidate");
        </LOOP>
    }

    onDraw(){
        System.out.println("CustomImageView.onDraw():start");
        //my code changes
    }
}

Now the timedifference between logs "CustomImageView.doDoubleTap():invalidate" and "CustomImageView.onDraw():start" is ~100ms. I want to reduce that to a max of 30ms.

来源:https://stackoverflow.com/questions/18269236/delay-in-calling-ondraw

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!