B4J Question B4J - B4XPage - ScrollPane and scrollbars

Elric

Active Member
Licensed User
Hi to everybody,

I wrote this code (using a similar code from B4A that's working):
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private ScrollPane1 As ScrollPane
    Private PaneToBeScrolled As Pane
End Sub

Public Sub Initialize

End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    ScrollPane1.LoadLayout("PaneToBeScrolledLayout",-1,-1)
End Sub

I designed a simple ScrollPane1 in main page and I create also a layout "PaneToBeScrolledLayout" containg a Pane with some random items. The PaneToBeScrolled is higher and wider than the ScrollPane1.

B4J hints me that it is not necessary to inizialize the scrollpane and the pane.

When I execute it, I get the mainpage with the ScrollPane1 with the PaneToBeScrolled and the random items.

The problem is that I've no chance to scroll it and no scrollbars are visible.
1603279440246.png

If I set the scrollbars always visible, I get the scrollbars with "length 1" (i.e. no chance to move them).
1603279516571.png

I'm sure that I'm making some mistake but I don't understand what.

I tried also to turn the declaration in B4XView
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private ScrollPane1 As B4XView
    Private PaneToBeScrolled As B4XView
End Sub
but is worse: the program doesn't start. I've found this discussion (https://www.b4x.com/android/forum/threads/b4xview-and-scrollpane-loadlayout.119586/#post-747985) but I don't understand the solution.

Thank you.
 

Elric

Active Member
Licensed User
Thank you!

I try with xCustomListView and I got some success!

However, if I correctly managed it, xCustomListView let me to decide whether the scroll have to be vertical or horizontal but it is no possible to have both.

I need to have the possibility to scroll both in vertical and in horizontal.
 
Upvote 0

Elric

Active Member
Licensed User
I think I've solved for the issue regarding the ScrollPane (it was silly, indeed):

B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private ScrollPane1 As ScrollPane
    Private Pane1 As B4XView
End Sub

Public Sub Initialize
    
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    
    
    Dim myPane As B4XView =xui.CreatePanel("")
    myPane.LoadLayout("PaneToBeScrolledLayout")
    Dim myHeight As Int = Pane1.Height
    Dim myWidth As Int = Pane1.Width
    myPane.SetLayoutAnimated(0, 0, 0, myWidth, myHeight)
    ScrollPane1.LoadLayout("PaneToBeScrolledLayout", myWidth, myHeight)
End Sub

I attach my example.
 

Attachments

  • B4XPage-Scroll ScrollPane.zip
    4 KB · Views: 113
Upvote 0

Elric

Active Member
Licensed User
Thank you a600000, I will use that for future!

At present I need to scroll vertical and horizontal at same time and seems that this could be only with ScrollPane.
 
Upvote 0
Top