Reputation: 1464
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
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 :
Android Pinch and Zoom Image in Activity
http://developer.android.com/training/animation/zoom.html
Upvotes: 3