user788511
user788511

Reputation: 1736

implement zoom on scrollView android

I am trying to create an application that employs the scrollView in Android. It so happens that scrollView does not support matrices. Therefore I can not do something like this:

Matrix matrix = new Matrix();
Matrix eventMatrix = new Matrix();
// possible touch states
final static int NONE = 0;
final static int DRAG = 1;
final static int ZOOM = 2;
int touchState = NONE;

Would anyone know if it is possible to attain the zooming as well as pinching functionality through other process? Appreciate the help.

Thanks.

[RE-EDIT]

The scrollView will serve as a container so that various UIs can be placed inside it. That way the scrollView can serve as one UI part.

Thanks.

Upvotes: 4

Views: 6935

Answers (3)

spatulamania
spatulamania

Reputation: 6663

Depending on your specific requirements here are a couple possible approaches to this problem:

  • You can create a view and adjust its layout parameters during the onScroll event.
  • For plain zooming you might want to look at the animation. This should effectively give you a zoom effect. For a specific element in the scroll view.
  • If you need to zoom the whole scrollView, you can surround it with a view container (eg LinearLayout) and perform the zoom on this view.

Upvotes: 2

Mike Ortiz
Mike Ortiz

Reputation: 4041

If your intention is to provide zoom capabilities to an image, then you're in luck! I wrote a fairly thorough class that extends ImageView to add pinch zoom and panning functionality, with boundary testing. Check it out here. If that's not what you want, then you'll have to provide more information about exactly what you want to do. But, this code might be adaptable to your needs.

Upvotes: 0

Noel
Noel

Reputation: 7410

I'm not sure what you are using the ScrollView for but you should take a look at this android developer article - Making sense of multitouch to get pinch/zoom functionality.

Upvotes: 1

Related Questions