• 12
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

How to zoom whole activity on multi touch?

Problem:

It's easy to zoom images and web views. But I want to zoom a whole activity. How can I do this?

Here, I provide wire-frame:

Wire-Frame-Of-Activity

From this you can understand, what I want to do.

Request

If you have any solution of this, then please share.
Thank you.

You can simulate zooming in and out by scaling the root activity view. Here's some starter code:

View v = findViewById(android.R.id.content); // get reference to root activity view
v.setOnClickListener(new OnClickListener() {
    float zoomFactor = 1.5f;
    boolean zoomedOut = false;

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

Note, the activity will zoom on single clicks as opposed to zooming upon double tap. Also, you probably want to animate the zooming. Look up Property Animation for details how to accomplish this.

[EDIT] For older API levels, you can use ScaleAnimation. You can also set the duration of the animation. However, a major caveat is that it only modifies the look of the view, but the actual view doesn't change.

if(zoomedOut) { // zoom in
    ScaleAnimation anim = new ScaleAnimation(1f, 1.5f, 1f, 1.5f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    anim.setDuration(500);
    anim.setFillAfter(true);
    v.startAnimation(anim);
    zoomedOut = false;
}
else {
    ScaleAnimation anim = new ScaleAnimation(1.5f, 1f, 1.5f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    anim.setDuration(500);
    anim.setFillAfter(true);
    v.startAnimation(anim);
    zoomedOut = true;
  • 16
Reply Report
      • 1
    • I suppose that is true. One could use ScaleAnimation, which is available for every API level, to achieve zoom. The drawback is that it only modifies where every view is drawn and not the actual View itself.

You can use setScaleX and setScaleY to zoom the complete activity view.

Then you need to set the pivot point with setPivotX and setPivotY.

The good examples with details for the whole activity zoom with multitouch:

1) MultiTouch for whole activity.

2) Zooming view completely.

  • 1
Reply Report