0

当手指在电话屏幕上移动时,我正在使用 sufaceview 绘制路径。但是当我快速移动手指时,所有点都没有注册,我面临着闪烁

    @Override
public void run() {
    while(running){ 
        running = true;
        if(!holder.getSurface().isValid())
            continue;

        Canvas canvas = holder.lockCanvas();
        canvas.drawCircle(right, bottom, 2, paint);
        holder.unlockCanvasAndPost(canvas);
    }
}

@Override
public boolean onTouch(View view, MotionEvent event){
    switch(event.getAction()){
    case MotionEvent.ACTION_MOVE:
        right = event.getX();
        bottom = event.getY();
        break;
    }
    return true;
}

有人可以帮忙吗?

在此先感谢,贾根

4

1 回答 1

0

onSurfaceCreate()在方法中启动线程。IE

@Override

public void surfaceCreated(SurfaceHolder holder)

{
     //write your code here
}

它需要连续的事件。首选此链接 http://www.mindfiresolutions.com/Using-Surface-View-for-Android-1659.php

于 2013-02-16T07:53:29.887 回答