Wish xCustomListView - ScrollToItem speed property.

Alexander Stolte

Expert
Licensed User
Longtime User
Thats the code:
B4X:
'Smoothly scrolls the list to the specified item.
Public Sub ScrollToItem(Index As Int)
    Dim offset As Float = Min(GetMaxScrollOffset, FindItemOffset(Index)) 'ignore
    #if B4i
    Dim nsv As ScrollView = sv
    If horizontal Then
        nsv.ScrollTo(offset, 0, True)
    Else
        nsv.ScrollTo(0, offset, True)
    End If
    #else if B4J
    JumpToItem(Index)
    #Else If B4A
    
    If horizontal Then
        Dim hv As HorizontalScrollView = sv
        hv.ScrollPosition = offset 'smooth scroll
    Else
        Dim nsv As ScrollView = sv
        nsv.ScrollPosition = offset
    End If
    #End If
End Sub
 

Alexander Stolte

Expert
Licensed User
Longtime User
in the thread is an example how to implement this with a timer
 

LucaMs

Expert
Licensed User
Longtime User

LucaMs

Expert
Licensed User
Longtime User
It is not the same as being able to slow down the speed of ScrollToItem as much as you should calculate ScrollViewOffsetY (or ScrollViewOffsetX) based on the index.

I could do it, I would have to develop some sort of my own xCLV, as you have done in other cases (eg CVLExpandable) but if it were implemented internally it would be much better for everyone.
 

LucaMs

Expert
Licensed User
Longtime User
It is not the same as being able to slow down the speed of ScrollToItem as much as you should calculate ScrollViewOffsetY (or ScrollViewOffsetX) based on the index.

I could do it, I would have to develop some sort of my own xCLV, as you have done in other cases (eg CVLExpandable) but if it were implemented internally it would be much better for everyone.
To do it myself I should have these functions (to be made public):
Dim offset As Float = Min(GetMaxScrollOffset, FindItemOffset(Index)) 'ignore
but I still think it would be much better if it implemented within the official xCLV.
 
Top