What is the best approach to implementing zoom functionality for a RecyclerView?
For API 11+, there is View.setScaleX () and View.setScaleY (); I have not tried them yet, but I would prefer to target API 10. This is because API 10+ covers over 99% of all devices on the play store, while increasing it to 11+ will cover only 94% (at least as of my last time checking; this is according to the AndroidStudio "New Project" dialog).
The best workflow I can think of:
- Override onTouchEvent () and dispatchDraw (), using ScaleGestureDetector and Canvas.scale () (as done here, answer by Schnodahipfe)
- For the parameters to Canvas.scale (), keep pivot Y at Canvas.getHeight () / 2, and let the RecyclerView take care of the vertical scrolling.
- Whenever RecyclerView vertical scroll is either 0 or at maximum, override scrolling to vary pivot Y instead of the default scroll position.
- When pivot Y is at minimum or maximum, go back to default scroll behavior so that the RecyclerView can give that end-of-scroll feedback to the user.
But it is a little complicated workflow. What is the best way to zoom for RecyclerView for API 10+?
As for what this is for, I want to write a handwritten-note-taking app.