B4A Library ZoomControls

Discussion in 'Additional libraries, classes and official updates' started by warwound, May 21, 2015.

  1. warwound

    warwound Expert Licensed User

    This small n simple library wraps the android ZoomControls class:
    http://developer.android.com/reference/android/widget/ZoomControls.html

    It provides the 'traditional' zoom controls as seen in the attached screengrab.

    ZoomControls
    Version: 1.10
    • ZoomControls
      Events:
      • ZoomInClick
      • ZoomOutClick
      Methods:
      • HasFocus As Boolean
        Returns true if this view has or contains focus.
      • Hide
      • Initialize (EventName As String)
      • Show
      Properties:
      • ZoomInEnabled As Boolean [write only]
      • ZoomOutEnabled As Boolean [write only]
      • ZoomSpeed As Long [write only]
        Sets how fast you get zoom events when the user holds down the zoom in or zoom out buttons.
        Default is 1000ms.

    ZoomControls is a standard android View so also has all the other standard View methods and properties.
    Usage is simple:

    Code:
    Sub Process_Globals
    End Sub

    Sub Globals
        
    Dim ZoomControls1 As ZoomControls
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
        ZoomControls1.Initialize(
    "ZoomControls1")
        
        
    '    using -2 for width and height which is android WRAP_CONTENT constant
        Activity.AddView(ZoomControls1, 00, -2, -2)
    End Sub

    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub

    Sub ZoomControls1_ZoomInClick
        
    ToastMessageShow("Zoom IN"False)
    End Sub

    Sub ZoomControls1_ZoomOutClick
        
    ToastMessageShow("Zoom OUT"False)
    End Sub
    Using the android WRAP_CONTENT constant makes the ZoomControls adjust it's size to fit it's 'native' dimensions.
    The ZoomControls will not expand if you set a width or height larger than it's native width or height.
    But it will clip/shrink in size if you set a smaller than native width or height.
    Experiment with the above code and that'll all make sense:

    Code:
    '    the ZoomControls doesn't expand to 200x150
    Activity.AddView(ZoomControls1, 00200dip150dip)
    Code:
    '    the ZoomControls shrinks/clips to 96x32
    Activity.AddView(ZoomControls1, 0096dip32dip)
    I haven't yet established what the ZoomControls actual native dimensions are - be sure to post those dimensions if you can find them.

    Library files and demo project attached.

    Martin.
     

    Attached Files:

    Last edited: May 22, 2015
    Douglas Farias, GMan, Phayao and 12 others like this.
  2. warwound

    warwound Expert Licensed User

    I've just updated ZoomControls to version 1.10.
    This update adds the new property:

    ZoomSpeed As Long [write only]
    Sets how fast you get zoom events when the user holds down the zoom in or zoom out buttons.
    Default is 1000ms.


    Version 1.10 attached to post #1 in this thread.
     
    johndb and thedesolatesoul like this.
  3. Mahares

    Mahares Well Known Member Licensed User

    I have been trying to figure out what this library is supposed to do, but have no idea. All I see is the zoom control on the screen in Warwound's example. Are you supposed to expand, zoom in, zoom out views or what. Can someone please explain how this library can be used, perhaps with a simple code.
    Thank you
     
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