質問

All, I've extended the ImageView in order to implement pinch and zoom scaling on the image. This is done by modifying the matrix and applying it to the image. Now, I am also overwriting the onDraw() to draw primitives (i.e. rectangles and circles). I've applied the matrix to the canvas and it appears to have handled the scaling properly, but the only problem is that that position is off on the drawn items. How do I go about translating the positions of the drawn items to reflect the new scale?

役に立ちましたか?

解決

There is an aproach without matrix, you can implement the pinch and zoom directly in the onDraw method. Check this blog post: http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html

  @Override
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    canvas.save();
    canvas.translate(mPosX, mPosY);
    mIcon.draw(canvas);
    canvas.restore();
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top