Android Question How to set CustomListView Scroll by defined height?

ronovar

Active Member
Licensed User
Longtime User
I have CustomListView that holds 10 items...i set height to 163dip and when i scroll down or up i dont get scroll by one page it scrolls half page down and up..i would like to scroll it up or down full size.

Here is code:

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim clvMasterCh As CustomListView
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")
   
    'INIT - Master CustoListView
    clvMasterCh.Initialize(Me, "clvMasterCh")
   
    'ADDVIEW - Master
    Activity.AddView(clvMasterCh.AsView, 97dip, 418dip, 407dip, 167dip)
   
    'ADD - Items
    For i = 1 To 10
        clvMasterCh.Add(CreateChannelListMaster(i, clvMasterCh.AsView.Width, 165dip), 163dip, i)
    Next   
End Sub

Sub CreateChannelListMaster(Text As String, Width As Int, Height As Int) As Panel
    'DEFINE - Panel
    Dim pnlMain As Panel
   
    'INIT - Panel
    pnlMain.Initialize("pnlMain")
   
    'COLOR - Panel
    pnlMain.Color = Colors.ARGB(127, 10, 10, 10)

    Return pnlMain
End Sub
 

ronovar

Active Member
Licensed User
Longtime User
The Width and Height is from example i don't use it in my real project.

CustoListView Height is defined in
clvMasterCh.Add and Height is set to value:
163dip

So can you give me example of hot to fix this issue? I need to scroll full page not half.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
You're setting the CLV height to 167dip:
'ADDVIEW - Master
Activity.AddView(clvMasterCh.AsView, 97dip, 418dip, 407dip, 167dip)

Then you add 10 items, which height is 163dip
clvMasterCh.Add(CreateChannelListMaster(i, clvMasterCh.AsView.Width, 165dip), 163dip, i)

CreateChannelListMaster should create the items of the CLV; I don't know what do you think about this routine (you name the panel created pnlMain, but it will a pnlItem)
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
I think what @ronovar is trying to say .. he has a CLV (scrollview) that is 167dip high.
He has added 10 panels .. each 165dip height.
When scrolling he wishes to stop at the next full panel in the CLV/scrollview , not half one panel and half of another panel.
Which i don't think can be done with scollview... but I might be wrong on both counts.

Maybe vertical SlidingPanels ...
 
Last edited:
Upvote 0

ronovar

Active Member
Licensed User
Longtime User
Thanks for replaying i fixed this by adding button setting tranparent button and put it in panel...then it scrolls excellent..this idea is from erel customscrollview class... just add code at the end of CreateChannelListMaster

B4X:
'DEFINE - Buttons
    Dim btnMaster As Button

    'INIT - Buttons
    btnMaster.Initialize("btnMaster")

    
    'COLOR - Buttons
    btnMaster.Color = Colors.Transparent

    
    'ADDVIEW - Buttons
    pnlMaster.AddView(btnMaster, 155dip, 2dip, 110dip, Height - 4dip)

So the point is to use panels height witch is taken into variable Height and then -4dip...in this example it is 167dip-4dip and is perfectly centered and scrolling item by item. This trick erel forget to mention in his super class customScrollView...i see i need to play with this class in bas file and have a loot of features that does not exists in android OS.

I would like to animate smoth this customScrollView so i see it is based on scrollview..how to define scrolling animation speed so that it scrolls nice and shiny.
 
Upvote 0
Top