Search code examples
androidandroid-layoutscrollviewandroid-scrollview

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.


Solution

  • 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.