Sercan Işık
Sercan Işık

Reputation: 11

How Android Zoom works properly?

Circle 1 in the image shows the correct location.But when I draw the same circle in the second circle area, there is a different background. I have trouble solving the problem.Can you help me ?

encountered error image

if (zooming) {
  zMatrix!!.reset()
  zMatrix!!.postScale(2 f, 2 f, zoomPos!!.x, zoomPos!!.y)
  zPaint!!.shader.setLocalMatrix(zMatrix)
  val src = RectF(zoomPos!!.x - 50, zoomPos!!.y - 50, zoomPos!!.x + 50, zoomPos!!.y + 50)
  val dst = RectF(0 f, 0 f, 100 f, 100 f)
  zMatrix!!.setRectToRect(src, dst, Matrix.ScaleToFit.CENTER)
  zMatrix!!.postScale(2 f, 2 f)
  zPaint!!.shader.setLocalMatrix(zMatrix)
  zPaint!!.color = Color.BLACK
  canvas ? .drawCircle(100 f, 100 f, 100 f, zPaint) // 1 Circle
  canvas ? .drawCircle(zoomPos!!.x, zoomPos!!.y, 100 f, zPaint) // 2 Circle
}

Upvotes: 1

Views: 57

Answers (0)

Related Questions