Android Tutorial Pinch Zoom and Move View tutorial

[Class] Pinch Zoom and Move View

I had the need for my purposes to do the Pinch Zoom in contemporary Move to a View, now I put my code available to anyone who might be in need, just to get ideas on what to do.

Is required the library Gesture and Reflection of Agraham.

- Click
- LongClick
- Change

- CanMove
- CanZoom
- LimitArea
- LimitBorder
- Zoom

[UPDATE 1.00]
I changed the code in Class.

[UPDATE 1.10]
Added the following methods:
SetIfCanMove() - sets whether the View may translare or not.
GetIfCanMove - returns if the View can translate.
SetZoom() - sets the zoom.
GetZoom - returns the current zoom.

[UPDATE 1.20]
Improved zoom function, now the zoom is localized based on the touches.
Renamed Class in PinchZoomAndMove.

[UPDATE 1.30]
Added the possibility to set the BringToFront.
Added the possibility to set the Tag for a multi-View.
Added the "Click" event for the View.

[UPDATE 1.40]
Added the LongClick event for the View.
Added methods SetIfCanMove() - sets whether the View may zoom or not.
Inserted also Library version in Zip Class.
Changed the type of data sent with the Click events and LongClick.

[UPDATE 1.41]
Now works in Obfuscated mode. Thanks Informatix!
Improvements to minors.

[UPDATE 1.43]
Now the events are generated in different activity from the Main.
Added the following methods:
SetLimitBorder() - if it is True, the View will not come out from the edges of its parent.
SetLimitArea() - if True, the edges of the View will remain within its parent.

[UPDATE 1.44]
Added the Change event for the View.

[UPDATE 1.45]
Converted the property into methods for ease of use, but this requires a small change to the code of the old methods.

For suggestions and bug reports please do not hesitate to post it here.


  • Screenshot_2012-11-02-20-02-13 (ridotta).jpg
    Screenshot_2012-11-02-20-02-13 (ridotta).jpg
    28.8 KB · Views: 2,384
    115 KB · Views: 4,276
Last edited:


Active Member
Licensed User
Longtime User
Now I am back from holiday I will take a look ans see if I can figure it out.

mauro vicamini

Active Member
Licensed User
Longtime User
Hello Everyone!
Why this code behave different from Android 2.3 and Android 5.0?
Sub Activity_Create(FirstTime As Boolean)
    Dim bmp As Bitmap
    Dim imv As ImageView
    Dim vWidth,vHeight As Float
    Dim c As Int

        bmp = LoadBitmap(File.DirRootExternal & "/bioimmagini","mypic.jpg")
        vWidth = 100%x
        vHeight = 100%y
        imv.Bitmap = bmp
        imv.Gravity = Gravity.FILL
        Activity.AddView(imv, 0,0,vWidth,vHeight)

        PZ.SetLimitBorder( False)
End Sub
On 2.3.6 and 4.4.2 works great (display and zoom image), on 5.0 it doesn't show nothing (the image is present in all devices in the same directory).
Last edited:


Licensed User
Longtime User

I have tried the module, and it works fine. Just a minor glitch: the tooltip of the Initialize method shows Tag as the 6th argument, while actually it is the 3rd.

Anyway, thank you very much!