Android Question how to zoom in and out image in the layout

Discussion in 'Android Questions' started by Makumbi, Jun 9, 2019.

  1. Makumbi

    Makumbi Active Member Licensed User

    Please help i wanted to zoom in and out the image i got from my URL so that it becomes more visible please help thanks in advance

    Code:
    #Region  Project Attributes
        
    #ApplicationLabel: B4A Example
        
    #VersionCode: 1
        
    #VersionName:
        
    'SupportedOrientations possible values: unspecified, landscape or portrait.
        #SupportedOrientations: unspecified
        
    #CanInstallToExternalStorage: False
    #End Region

    #Region  Activity Attributes
        
    #FullScreen: False
        
    #IncludeTitle: True
    #End Region

    Sub Process_Globals
        
    'These global variables will be declared once when the application starts.
        'These variables can be accessed from all modules.

    End Sub

    Sub Globals
        
    'Dim ImageView3 As ImageView
        'Dim ImageView2 As ImageView
        Dim ImageView1 As ImageView
        
    'Dim ImageView4 As ImageView
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
        
    Activity.LoadLayout("1")
        
    'ImageView1.
    End Sub

    Sub Activity_Resume
        
    Dim links As Map
        links.Initialize
        links.Put(ImageView1, 
    "http://kccug.com/KabojjaApp/work/P1.png")
        
    'links.Put(ImageView2, "http://www.basic4ppc.com/basic4android/images/SS-2013-03-04_11.42.38.png")
        'links.Put(ImageView3, "http://www.basic4ppc.com/basic4android/images/SS-2013-03-04_11.52.19.png")
        'links.Put(ImageView4, "http://www.basic4ppc.com/basic4android/images/SS-2012-02-06_12.45.56.png")
        CallSubDelayed2(ImageDownloader, "Download", links)
    End Sub

    Sub Activity_Pause (UserClosed As Boolean)
        
    CallSub(ImageDownloader, "ActivityIsPaused")
    End Sub

    Code:
    #Region  Service Attributes
        
    #StartAtBoot: False
    #End Region

    Sub Process_Globals
        
    Private cache As Map
        
    Private tasks As Map
        
    Private ongoingTasks As Map
    End Sub

    Sub Service_Create
        tasks.Initialize
        
    cache.Initialize
        ongoingTasks.Initialize
    End Sub

    Sub Service_Start (StartingIntent As Intent)

    End Sub

    Sub Service_Destroy

    End Sub

    Sub Download (ImageViewsMap As Map)
        
    For i = 0 To ImageViewsMap.Size - 1
            tasks.Put(ImageViewsMap.GetKeyAt(i), ImageViewsMap.GetValueAt(i))
            
    Dim link As String = ImageViewsMap.GetValueAt(i)
            
    If cache.ContainsKey(link) Then
                
    Dim iv As ImageView = ImageViewsMap.GetKeyAt(i)
                iv.SetBackgroundImage(
    cache.Get(link))
             
            
    Else If ongoingTasks.ContainsKey(link) = False Then
                ongoingTasks.Put(link, 
    "")
                
    Dim j As HttpJob
                j.Initialize(link, Me)
                j.Download(link)
            
    End If
        
    Next
    End Sub

    Sub JobDone(Job As HttpJob)
        ongoingTasks.Remove(Job.JobName)
        
    If Job.Success Then
            
    Dim bmp As Bitmap = Job.GetBitmap
            
    cache.Put(Job.JobName, bmp)
            
    If tasks.IsInitialized Then
                
    For i = 0 To tasks.Size - 1
                    
    Dim link As String = tasks.GetValueAt(i)
                    
    If link = Job.JobName Then
                        
    Dim iv As ImageView = tasks.GetKeyAt(i)
                        iv.SetBackgroundImage(bmp)
                    
    End If
                
    Next
            
    End If
        
    Else
            
    Log("Error downloading image: " & Job.JobName & CRLF & Job.ErrorMessage)
        
    End If
        Job.Release
    End Sub
    Sub ActivityIsPaused
        tasks.Clear
    End Sub
     

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice