btrballin
btrballin

Reputation: 1464

How to create a zoomable activity in Android Studio?

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.

Upvotes: 3

Views: 16065

Answers (1)

Saeed Masoumi
Saeed Masoumi

Reputation: 8916

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

Upvotes: 3

Related Questions