Hi, I'm trying to populate a ScrollPane with canvases that each have something different drawn on them, like the example below. I'm initializing a canvas, drawing a rectangle on it, then adding it to the scrollpane.
The rectangles are not visible; what am I doing wrong?
The "Main" layout file simply contains the ScrollPane ScrollPane1 and nothing more. The ScrollPane.bjl file is blank.
EDIT: My end goal is to create a bar graph which might be wider that the program window, so some type of scrolling is required. If someone has another idea as to how I might accomplish that with a different method I would be interested in hearing it.
The rectangles are not visible; what am I doing wrong?
B4X:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private ScrollPane1 As ScrollPane
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Main") 'Load the layout file.
MainForm.Show
AppInit
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub AppInit
ScrollPane1.SetVScrollVisibility("NEVER")
ScrollPane1.LoadLayout("ScrollPane.bjl",0,0)
Dim n As Pane = ScrollPane1.InnerNode
For i = 0 To 100
Dim cvs As Canvas
cvs.Initialize("cvs")
cvs.DrawRect(0,0,20,i,fx.Colors.Cyan,True,0)
n.AddNode(cvs,i*20,0,-1,-1)
Next
n.PrefWidth = (i*20) + 20
End Sub
The "Main" layout file simply contains the ScrollPane ScrollPane1 and nothing more. The ScrollPane.bjl file is blank.
EDIT: My end goal is to create a bar graph which might be wider that the program window, so some type of scrolling is required. If someone has another idea as to how I might accomplish that with a different method I would be interested in hearing it.
Last edited: