rotate and resize the image view with single finger in android

后端 未结 3 1351
执笔经年
执笔经年 2020-12-29 15:22

I am developing an app which has feature that resizing and rotating the imageview by dragging its bottom right corner button.

I saw one app which has feature that if

3条回答
  •  灰色年华
    2020-12-29 16:03

    I'm assuming the rotation/scaling happens from the image center? In that case, it's simple trigonometry to find the rotation angle and the size:

    Diagram of triangle formed between picture center and finger

    Calculate dx and dy of the finger's coordinates minus the center coordinates. Math.atan2(dy, dx) is the rotation angle (in radians) and Math.hypot(dx,dy) can be used for the relative size, or just double the dx/dy and use directly.

提交回复
热议问题