延迟调用onDraw()

时间:2013-08-16 08:42:52

标签: android android-canvas ondraw

我正在编写一个代码,需要在一秒钟内多次更新UI以显示动画。但是在调用invalidate之后,onDraw()方法在大约100ms后被调用,因此屏幕被重新绘制的次数减少了每秒只有4或5次。

我想知道是什么原因导致invalidate()命令和onDraw方法调用之间的时间差异。

有什么方法可以减少延迟,这样我的动画可以很流畅吗? 提前谢谢。

这是一个很大的代码,我只是发布它的简单格式:

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

现在日志之间的时差 “CustomImageView.doDoubleTap():使”和“CustomImageView.onDraw()无效:启动”是~100ms。 我希望将其减少到最多30毫秒。

0 个答案:

没有答案
相关问题