How to pinch zoom an edittext in android?

后端 未结 3 1838
失恋的感觉
失恋的感觉 2021-01-15 11:31

Please suggest a way to zoom all the contents of the edittext when a pinch gesture is detected. Want to zoom like typical text editor apps like KingSoft and quickoffice.

3条回答
  •  暖寄归人
    2021-01-15 12:04

    It's going to be nasty, but you can subclass EditText.

    In your subclass, override onTouch and pass its values to a ScaleGestureDetector. Store the detected scale as a member variable.

    Override onDraw, and call canvas.scale() with your scale value prior to calling through to super.onDraw.

    This is likely to wreak havoc with the caret and edit controls.

提交回复
热议问题