Android Question Scrollview 2D with locked first row when scrolling horizontal

ViMeAv ICT

Member
Licensed User
Longtime User
When using scrollview2d it is easy to navigate in a table, which is longer and wider than the screen.
But now I'm curious to find out if it is possible to use scrollview2d and navigate in a table, with the first
column locked when moving horizontally. So only the columns 2 until last are moved horizontally.

When navigating vertically all rows are working the same.

Actually I guess we need a scrollview for the first column, and scrollview2d for the other columns.
And a connection between them, to update okay, when scrolling up/down.
Maybe, column one, only scrolling vertically, other columns only scrolling horizontally.
 

klaus

Expert
Licensed User
Longtime User
You need two scrollviews a Scrollview for the fixed columns and the ScrollView2D for the others.
I use this in the FlexibeTable Class.
Code for the synchronisation.
SVF is the ScrollView and SV2 is the ScrollView2D.
SVFScrolls and SV2Scrolls are two global variables to avoid a looping between the two scrollviews.
B4X:
Private Sub SVF_ScrollChanged(Position As Int)
    SVFScrolls = True
    If SV2Scrolls = False Then
        SV2.VerticalScrollPosition = Position
    End If
    SVFScrolls = False
End Sub

Private Sub SV2_ScrollChanged(PosX As Int, PosY As Int)
    SV2Scrolls = True
    If SVFScrolls = False Then
        SV2PosX = PosX
        SVF.ScrollToNow(PosY)
    End If
End Sub

EDIT: Removed the Scroll routine calls.
 
Last edited:
Upvote 0

ViMeAv ICT

Member
Licensed User
Longtime User
I get this warning:

1619009258901.png


What can this be?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I have got this kind of message: Unexpected event (missing RaiseSynchronousEvents)
I assume that you are using this in a CustomView.
If yes, it is considered as harmless. You can ignore it.

Or does the program crash? In that case I don't what the problem might be.
 
Upvote 0

ViMeAv ICT

Member
Licensed User
Longtime User
No crash, customview.
I use for 2d, smoothscroll instead of VerticalScrollPosition.
Works almost perfect. Sometimes a few pixels below (---- ____)
 
Upvote 0
Top