Android Question TouchImageView and Panel

Vittorio

Member
Licensed User
Longtime User
Good afternoon,

I am developing an app using the sliding panels tutorial by Erel. It work fine!

Now I am trying to add zoomable images; to do this I would use the warwound's TouchImageView library but it doesn't work.

Here there is the code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
 
  
    '****** TOUCH
    Activity.AddMenuItem("Create Log", "CreateLog")
  
    TouchImageView1.Initialize("TouchImageView1")
    Activity.AddView(TouchImageView1, 0, 0, 100%x, 100%y)
  
    TouchImageView1.MinScale=0.25            '    default is 0.5
    TouchImageView1.MaxScale=2                '    default is 1.5
    TouchImageView1.TranslatePadding=128dip    '    default is 64dip
  
    TouchImageView1.Gravity=Gravity.FILL
      
    Dim Bitmap1 As Bitmap
      
   '************
  
    'TouchImageView1.ScaleSrcRectToDestRect(SourceImageRect, TouchImageViewRect, "CENTER")    '    make string a static constant in library
      
    Dim panels(6) As Panel
    Dim UsedImg As String
    For i = 0 To panels.Length - 1
        panels(i).Initialize("panels")
        panels(i).Color = Colors.White  'Colors.RGB(Rnd(0, 255), Rnd(0, 255), Rnd(0, 255))
        If i=0 Then Then
            UsedImg="bro_inizio1.png"
        End If
        If i=1 Then Then
            UsedImg="bro_inizio2.png"
          End If
        If i>1 Then
            UsedImg="calcolatrice.gif"
        End If
        Bitmap1.Initialize(File.DirAssets, UsedImg)
          
        TouchImageView1.SetBitmap(Bitmap1)
      
        If FirstTime Then
            '    Rect parameters are: left, top, right, bottom
            SourceImageRect.Initialize(0, 0, Bitmap1.Width, Bitmap1.Height)
            TouchImageViewRect.Initialize(0, 0, TouchImageView1.Width, TouchImageView1.Height)
        End If
      
      
        TouchImageView1.ScaleSrcRectToDestRect(SourceImageRect, TouchImageViewRect, "CENTER")    '    make string a static constant in library
        Activity.AddMenuItem("Create log", "CreateLog")
        Activity.AddMenuItem("Toggle touch", "Toggle")
        panels(i).AddView(TouchImageView1, 0, 0, 100%x, 100%y)
 
    
        Activity.AddView(panels(i), 100%x, 0, 100%x, 100%y - 80dip) 'add the panel to the layout
      
        'Activity.AddMenuItem("Panel #" & i, "Menu")
    Next
 
    'add button menu
    btnMenu.Initialize("Menu")
    btnMenu.Textsize=15
    btnMenu.Text = "Menu principale"
    Activity.AddView(btnMenu, 20%x, 100%y - 75dip, 200dip, 50dip)
    'Activity.AddView(btnMenu, 40%x, 100%y - 75dip, 100dip, 50dip)
 
    'add the Left and Right button
    btnLeft.Initialize("Left")
    btnLeft.Textsize=15
    btnLeft.Text = ">"
    Activity.AddView(btnLeft, 85%x, 100%y - 75dip, 50dip, 50dip)
    'Activity.AddView(btnLeft, 60%x, 100%y - 75dip, 100dip, 50dip)
    btnRight.Initialize("Right")
    btnRight.Textsize=15
    btnRight.Text = "<"
    Activity.AddView(btnRight, 0%x, 100%y - 75dip, 50dip, 50dip)
    'Activity.AddView(btnRight, 10%x, 100%y - 75dip, 100dip, 50dip)
 
    'Load Bitmaps for indicator
    ActiveBitmap.Initialize(File.DirAssets, "indicator_active.png")
    InactiveBitmap.Initialize(File.DirAssets, "indicator_inactive.png")
  
      
    '*****************************
    'Initialize the SlidingData object and set the array of panels.
    'Then we call SlidingPanels.Initialize to prepare the animation objects.
    'The last call to ChangePanel brings the first panel.
    sd.Initialize
    SlidingPanels.Initialize(sd, panels, True, 150)
    sd.currentPanel = currentPanelBeforePaused - 1
    Indicator = SlidingPanels.CreatePageIndicator(panels.Length, InactiveBitmap, 120dip, 16dip)
    Activity.AddView(Indicator, (100%x - 120dip) / 2, 0, 120dip, 16dip)
    Indicator.BringToFront
    '****
    ChangePanel(0)
End Sub

Thank you for helping
 

Vittorio

Member
Licensed User
Longtime User
The AHViewPager library is fantastic and powerful. Unfortunately I don't see how it can solve my original problem: zoom function.

In short words: The App is done for medical purposes; The patient can keep note of visits, lab reults, medicines, etc. I need to add some pages of medical information. Those pages are taken from a small book (scanned) and are very small when seen on the phone screen.

How I can implement the zoom? Do you think I can use TouchImageView together with AHViewPager?

Thank you,
Vittorio
 
Upvote 0

phukol

Active Member
Licensed User
Longtime User
Hi just wanna ask for a sample of using two or more touchimageview in one activity. Thanks
 
Upvote 0
Top