Canvas.DrawText in ScrollView

danijel

Active Member
Licensed User
Longtime User
How to make canvas.drawtext scrolable?

for example I want to scroll down, but text is fixed on background and visible all the time.

B4X:
Sub Globals
   Dim SV As ScrollView
   Dim canvas1 As Canvas
End Sub

Sub Activity_Create(FirstTime As Boolean)
   SV.Initialize(1000dip)
   Activity.AddView(SV,0,0,100%x,100%y)
   canvas1.Initialize(Activity)
   canvas1.DrawTextRotated("Text",50dip,50dip,Typeface.MONOSPACE,30,Colors.Yellow,"CENTER",135)
End Sub

I probably need do something like this

B4X:
   canvas1.Initialize(SV)

but i dont know how :confused:
 

PenguinHero

Member
Licensed User
Longtime User
Hi danijel,

You almost had what you needed.

This example code should work for you. You will need to adjust your scrollview panel height and widths to suit for needs.

B4X:
Sub Activity_Create(FirstTime As Boolean)
  SV.Initialize(1000dip)
  SV.Panel.Height = 500dip
  SV.Panel.Width = 500dip
  Activity.AddView(SV,0,0,100%x,100%y)
  canvas1.Initialize(SV.Panel)
  canvas1.DrawTextRotated("Text",50dip,50dip,Typeface.MONOSPACE,30,Colors.Yellow,"CENTER",135)
End Sub
 
Upvote 0
Top