【发布时间】:2019-12-06 09:00:49
【问题描述】:
我正在编写绘图应用程序并使用画布。我创建了我的 surfaceView 并覆盖了 onTouch 函数来跟踪用户的手指运动。但是当用户绘制surfaceView时闪烁。我该如何解决?
这是我的绘图代码:
override fun onTouchEvent(event: MotionEvent?): Boolean {
if (event != null)
if (event.action == MotionEvent.ACTION_MOVE && holder != null) {
thread {
val canvas = holder.lockCanvas()
canvas.drawBitmap(brush,
event.x - brush.width.div(2),
event.y - brush.height.div(2),
null)
holder.unlockCanvasAndPost(canvas)
}.join()
}
return true
}
【问题讨论】:
标签: android canvas surfaceview