Android Question ZoomImageView Library - Capture Zoomed Properties?

RichardN

Well-Known Member
Licensed User
Longtime User
The ZoomImage view library allows us to present bitmap images in a manner where the user can scroll in and navigate around the images using natural gestures.

Is it possible to capture the current x/y centre of the view and zoom value so that when the activity is restarted you can reproduce the image as it was last seen to the user?
 

LucaMs

Expert
Licensed User
Longtime User
Try "playing" with the following values:
B4X:
Private Sub ZoomImageView1_Click
    Log(ZoomImageView1.pnlBackground.Left & "." & ZoomImageView1.pnlBackground.Top & " - " & ZoomImageView1.pnlBackground.Width & "." & ZoomImageView1.pnlBackground.Width)
    Log(ZoomImageView1.ImageView.Left & "." & ZoomImageView1.ImageView.Top & " - " & ZoomImageView1.ImageView.Width & "." & ZoomImageView1.ImageView.Width)
    Log(" ")
End Sub
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
see
 
Upvote 0

RichardN

Well-Known Member
Licensed User
Longtime User
Thanks @TILogistic for the link but that seems to be for a different purpose.

The suggestion of @LucaMs was more useful. I was hoping for an easier solution but you need to save & restore all 8 properties of the ZoomImageView BG and Image to get the desired result. With a landscape image the Background.Left always returns zero and the Top value always zero with a portrait image. Sadly you need to save all 8 values to cover all eventualities.

Save all 8 properties:
If MapName.Length <> 0 Then            'display the last viewed map
                    
        bm = xui.LoadBitmap(File.DirAssets,MapName)
        ZoomImageView1.SetBitmap(bm)
        
        ZoomImageView1.pnlBackground.Top = KVS.Get("PanelBGtop")
        ZoomImageView1.pnlBackground.Height = KVS.Get("PanelBGheight")
        ZoomImageView1.pnlBackground.Left = KVS.Get("PanelBGleft")
        ZoomImageView1.pnlBackground.Width = KVS.Get("PanelBGwidth")
    
        ZoomImageView1.ImageView.Top = KVS.Get("ImageTop")
        ZoomImageView1.ImageView.Height = KVS.Get("ImageHeight")
        ZoomImageView1.ImageView.Left = KVS.Get("ImageLeft")
        ZoomImageView1.ImageView.Width = KVS.Get("ImageWidth")
        
        ZoomImageView1.mBase.Visible = True
        
End If
 
Upvote 0
Top