B4J Library [B4X] SD_ImageView

Discussion in 'B4J Libraries & Classes' started by Star-Dust, May 6, 2019.

  1. Star-Dust

    Star-Dust Expert Licensed User

    I created a custom ImageView view that allows you to upload an image from the web.
    Just pass the URL as a parameter
    This class is B4X but does not depend on the XUI library

    SD_ImageView

    Author: Star-Dust
    Version: 0.02
    • SD_ImageView
      • Events:
        • LongClick
        • OneClick
      • Fields:
        • NatObject As ImageView
        • Zoom As ImageView
      • Functions:
        • BringToFront
        • DesignerCreateView (Base As Panel, Lbl As Label, Props As Map)
        • GetBase
        • Initialize (Callback As Object, EventName As String)
        • RemoveViewFromParent
        • RequestFocus
        • SendToBack
      • Properties:
        • Bitmap As Bitmap [write only]
        • Enable As Boolean [write only]
        • Gravity As Int [write only]
        • Height As Float [write only]
        • Left As Float [write only]
        • PreserveRatio As Boolean [write only]
        • Tag As Object [write only]
        • Top As Float [write only]
        • UrlBitmap As String [write only]
        • Visible As Boolean [write only]
        • Width As Float [write only]

    SAMPLE
    Code:
    Sub Globals
        
    'These global variables will be redeclared each time the activity is created.
        'These variables can only be accessed from this module.
        Private SD_ImageView1 As SD_ImageView
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
        
    'Do not forget to load the layout file created with the visual designer. For example:
        Activity.LoadLayout("Layout1")
        Sleep(
    1000)
        SD_ImageView1.Gravity=
    Gravity.FILL
        SD_ImageView1.UrlBitmap=
    "https://b4x-4c17.kxcdn.com/android/forum/data/avatars/l/0/1.jpg?1469350209"
    End Sub

    Sub SD_ImageView1_OneClick
     
    End Sub

    Sub SD_ImageView1_LongClick
     
    End Sub
    ok.png
     

    Attached Files:

    Last edited: May 8, 2019
  2. Almora

    Almora Active Member Licensed User

    great..
    Can zoom feature be added?
     
  3. Star-Dust

    Star-Dust Expert Licensed User

    What kind of zoom do you want to get?
    Enlarge the view?
    Enlarge a coordinate from code?
    Enlarge with pinch to zoom?
     
    Last edited: May 7, 2019
  4. Almora

    Almora Active Member Licensed User

    As in webview
    pinch ti zoom
     
  5. Star-Dust

    Star-Dust Expert Licensed User

    It could be done, we'll see at the next update
     
    Almora and Johan Hormaza like this.
  6. Star-Dust

    Star-Dust Expert Licensed User

    Fixed a bugs in the manifest. Updated to post#1
     
    DonManfred, Erel and José J. Aguilar like this.
  7. Star-Dust

    Star-Dust Expert Licensed User

    Update rel 0.02
    Add Pinch to Zoom
    Code:
    SD_ImageView1.Zoom=True
    SD_ImageView1.Gravity=
    Gravity.FILL ' Only Android
    SD_ImageView1.UrlBitmap="https://b4x-4c17.kxcdn.com/android/forum/data/avatars/l/0/1.jpg?1469350209"
    Video1.gif

    It's not perfect but it works. Besides, I can't do everything :p

    PS. Obviously it only works on Android and iOs the zoom and it doesn't work for desktop. There are no mice that click at two different points :D:D:D
     
    Last edited: May 8, 2019
    Peter Simpson, aeric, Erel and 4 others like this.
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