2

I am trying to implement a view that will allow the user to pan around a view (just like 2D scroll view). Additionally the view should have a possibility to zoom out (to see more of the area). Dynamically I want to add subviews to that view (my custom ones) that will be positioned absolutely in relation to top left corner of the view.

I have managed to find a way of creating a 2D ScrollView using ScrollView and HorizontalScrollView, but I have no idea how to add zooming to it.

Do you guys have a solution to this or done sth similar?

BartoszCichecki
  • 2,227
  • 4
  • 28
  • 41

1 Answers1

-1

You don't need to combine both scroll views. You can extend any View for this purpose. Basically the exploit lies in GestureDetector to detect all motions like pinch or pan (as in scroll). For example ScaleGestureDetector with onScale method which can be used for scaling or zooming. The solutions are already available:

Pinch zoom for custom view

Smooth scrolling in Android

Community
  • 1
  • 1
inmyth
  • 8,880
  • 4
  • 47
  • 52