Android Question Looking for an example about scrolling an image

Serge Bertet

Active Member
Licensed User
Hi,

I am able to load an image 1000x1000 pixels, on screen I can see the top of the image but never the bottom even when scrolling fullScroll bottom. My app is landscape only.

B4X:
Sub play(id As Int)
Dim name As String
Dim pth As String
Dim speed As Int
Dim bmp As Bitmap

    name = su.DecodeUrl(Starter.db.ExecQuerySingleResult("SELECT name FROM songlist WHERE ID = " & id), "UTF8")
    pth = su.DecodeUrl(Starter.db.ExecQuerySingleResult("SELECT path FROM songlist WHERE ID = " & id), "UTF8")
    speed = Starter.db.ExecQuerySingleResult("SELECT scrollspeed FROM songlist WHERE ID = " & id)
   
    bmp.Initialize(pth, name)

    Dim bw As Int = bmp.Width  ' 1000
    Dim bh As Int = bmp.Height  ' 1000
    Dim Ar As Double = bh/bw    ' ratio of 1

    ImageView.Initialize("")

    ImageView.SetLayout(0dip, 0dip, 100%x, 100%x*Ar)
    ImageView.Gravity = Bit.Or(Gravity.CENTER, Gravity.FILL)
    ImageView.Bitmap = bmp

    ScrollView2D.SetLayout(0, 0, 100%x, 100%x) ' *Ar)
    ScrollView2D.Panel.Width = 100%x
    ScrollView2D.Panel.Height = 100%y
    ScrollView2D.Panel.AddView(ImageView, 0dip, 0dip, 100%x, 100%x*Ar)
    ScrollView2D.FullScroll(1, True, True)
End Sub

In the designer there is only a ScrollView2D

Unable to find an example for this case.

Serge
 

Serge Bertet

Active Member
Licensed User
Thx for your answer, I'll try that
I got no errors with this name ... yes this is the name of the component itself, maybe better to change ... I'll see.
Serge
 
Upvote 0

Serge Bertet

Active Member
Licensed User
OK good! It's working with this code :

B4X:
    bmp.Initialize(pth, name)

    Dim bw As Int = bmp.Width
    Dim bh As Int = bmp.Height
    Dim Ar As Double = bh/bw

    ImageView.Initialize("")

    ImageView.SetLayout(0dip, 0dip, 100%x, 100%y)
    ImageView.Gravity = Bit.Or(Gravity.LEFT, Gravity.TOP)
    ImageView.Bitmap = bmp

    SV2D.SetLayout(0, 0, 100%x, 100%y)
    SV2D.Panel.Width = bw
    SV2D.Panel.Height = bh

    SV2D.DisableTouchEventInterception(True)  ' Trying to disable user's actions
    SV2D.FadingEdges(False)

    SV2D.Panel.AddView(ImageView, 0dip, 0dip, bw, bh)
End Sub

I don't know if there is a way to disable users actions on screen since the scrolling will be done by a timer.

Thx.
 
Last edited:
Upvote 0
Top