4

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.

user788511
  • 1,726
  • 2
  • 30
  • 52

3 Answers3

2

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.
spatulamania
  • 6,613
  • 2
  • 30
  • 26
1

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.

Noel
  • 7,350
  • 1
  • 36
  • 26
  • The question is about zooming a scrollview, not handling multitouch events. – spatulamania Oct 07 '11 at 04:38
  • 2
    Actually, the question also asked "Would anyone know if it is possible to attain the zooming as well as pinching functionality through other process?". I could be wrong but I'm pretty sure "pinching" is a multitouch gesture ;) – Noel Oct 07 '11 at 18:55
0

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.

Community
  • 1
  • 1
Mike Ortiz
  • 4,031
  • 4
  • 27
  • 54
  • Hey Mike, thanks for the advice, however I am not working on images per say. I have re-edited my question so as to actually relay the purpose of my code. Thanks. – user788511 Oct 06 '11 at 06:06