Dim SV As ScrollView
Dim Pnl As Panel
Dim Cnv As Canvas
Dim Pth As Path
SV.Initialize(1000dip)
Pnl.Initialize("")
Activity.AddView(SV,10%x,10%y,20%x,20%y)
Activity.AddView(Pnl,10%x,10%y,20%x,20%y) ' <-- add the panel view in activity
Cnv.Initialize(Pnl)
Pth.Initialize(5%x,5%y)
Pth.LineTo(8%x,5%y)
Cnv.DrawPath(Pth,Colors.Black,False,1)
Pnl.Invalidate
i dont know if the Pnl=SV.Panel will work but lets see
B4X:
Dim SV As ScrollView
Dim Pnl As Panel
Dim Cnv As Canvas
Dim Pth As Path
SV.Initialize(1000dip)
Activity.AddView(SV,10%x,10%y,100%x,90%y)
Pnl.Initialize("") '<- initiliaze the panel
Activity.AddView(Pnl,0,0,50%x,50%y) ' <-- add the panel in activity
' ---- >-Pnl=SV.Panel '<-- dont use.. it will not work
Cnv.Initialize(Pnl)
Pth.Initialize(5%x,5%y)
Pth.LineTo(8%x,5%y)
Cnv.DrawPath(Pth,Colors.Black,False,1)
Pnl.Invalidate
if it does not work.. upload your project as zip and il try to fix it
edit:
B4X:
SV.Panel.Addview(pnl,0,0,sv.width,sv.height) '<--- add panel to scrollview
The file you sent me works!
My conclusion is that Pnl=SV.Panel, which I've used before with no problem, does not accept a Canvas in the panel of a ScrollView.
Thanks for your help. Now I can move forward again!
You don't need to add a new Panel to the ScrollView.
This code works:
B4X:
Sub Globals
Private scvTest As ScrollView
Private cvsTest As Canvas
Private pnlScvTest As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
scvTest.Initialize(2000dip)
Activity.AddView(scvTest, 10dip, 10dip, 100%x - 20dip, 100%y - 20dip)
pnlScvTest = scvTest.Panel
pnlScvTest.Width = scvTest.Width
cvsTest.Initialize(pnlScvTest)
cvsTest.DrawLine(0, 0, 200dip, 100dip, Colors.Red, 2dip)
End Sub
What you were missing is that scvTest.Panel.Width is equal to -1 which means fill the parent view.
Setting the width to a value > 0, pnlScvTest.Width = scvTest.Width, solves the problem.
You don't need to add a new Panel to the ScrollView.
This code works:
B4X:
Sub Globals
Private scvTest As ScrollView
Private cvsTest As Canvas
Private pnlScvTest As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
scvTest.Initialize(2000dip)
Activity.AddView(scvTest, 10dip, 10dip, 100%x - 20dip, 100%y - 20dip)
pnlScvTest = scvTest.Panel
pnlScvTest.Width = scvTest.Width
cvsTest.Initialize(pnlScvTest)
cvsTest.DrawLine(0, 0, 200dip, 100dip, Colors.Red, 2dip)
End Sub
What you were missing is that scvTest.Panel.Width is equal to -1 which means fill the parent view.
Setting the width to a value > 0, pnlScvTest.Width = scvTest.Width, solves the problem.