3

Basically, I just need my activity to feely zoom with the standard gestures: spread to zoom in, pinch to zoom out, and double tap to zoom in and double tap again to zoom back out

So far all my activities only fit to scale. My activity for the zoomable page will simply have an ImageView.

I tried looking for answers but could find a consistent one.

1 Answer 1

3

Here is a simple zoom for a View

 View view =getLayoutInflater().inflate(R.layout.activity_main,null); // get reference to root activity view
        setContentView(view);

        view.setOnClickListener(new View.OnClickListener() {
            float zoomFactor = 2f;
            boolean zoomedOut = false;

            @Override
            public void onClick(View v) {
                if(zoomedOut) {
                    v.setScaleX(1);
                    v.setScaleY(1);
                    zoomedOut = false;
                }
                else {
                    v.setScaleX(zoomFactor);
                    v.setScaleY(zoomFactor);
                    zoomedOut = true;
                }
            }
        });

But for more information take a look these links :

Zoomable View in Android?

Android Pinch and Zoom Image in Activity

http://www.zdnet.com/article/how-to-use-multi-touch-in-android-2-part-6-implementing-the-pinch-zoom-gesture/

http://developer.android.com/training/animation/zoom.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.