Android Example Horizontal ScrollPage

Hi everybody!
I want to share this simple example of an HorizontalScrollView that works like ViewPager. Main difference between this and ViewPager is that HorizzontalScrollview has an only inner panel: this means that you can put inside it views that are larger then page width.

Code is simple
B4X:
Private Sub hsvPages_Touch(ViewTag As Object, Action As Int, X As Float, y As Float, MotionEvent As Object) As Boolean
    Dim val As Double = 0
    Select Action
        Case 0    ' ACTION_DOWN
            t1 = DateTime.Now
            x0 = x
        Case 1    ' ACTION_UP
            Dim dt As Long = DateTime.Now-t1
            If dt < 200 And Abs(x-x0) > 24dip And Abs(X-x0)<pnlScv.Width/2-1 Then
                If (x - x0) < 0 Then val = 1 Else val = -1
            End If
            pnlScv.ScrollPosition = (Round2((pnlScv.ScrollPosition)/pnlScv.Width,0)+val)*pnlScv.Width
            Return True
        End Select
    Return False
End Sub

Attached example
 

Attachments

  • HorizzontalScrollPage.zip
    7.1 KB · Views: 623

Emme Developer

Well-Known Member
Licensed User
Longtime User
An example made with this scrollview. Code is attached.
 

Attachments

  • online.gif
    online.gif
    428.8 KB · Views: 578
  • HorScvPanel.zip
    7.3 KB · Views: 514
Top