Android Question ScrollView doesn't scroll

GaNdAlF89

Active Member
Licensed User
Longtime User
Hi!! I have this code in Activity_Create sub:

There is a label on a Scrollview (which is on a main panel)
B4X:
   PanelDescrizione.Initialize("PanelMain")
   PanelDescrizione.Enabled = True
   PanelDescrizione.Visible = True

   #Region ScrollViewTesto
   ScrollViewTesto.Initialize(60%y)
   ScrollViewTesto.Enabled = True
   ScrollViewTesto.Visible = True
 
   #Region LabelTesto
   LabelTesto.Initialize("LabelTesto")
   LabelTesto.Enabled = True
   LabelTesto.Visible = True
   LabelTesto.Text = STR2
   LabelTesto.TextColor = Colors.Black
   LabelTesto.Gravity = Bit.Or(Gravity.TOP,Gravity.CENTER_HORIZONTAL)
   LabelTesto.TextSize = 22
 
   ScrollViewTesto.Panel.AddView(LabelTesto,0,0,94%x,60%y)
   #End Region
 
   PanelDescrizione.AddView(ScrollViewTesto,3%x,15%y,94%x,60%y)
   #End Region
 
   Activity.AddView(PanelDescrizione,0,0,100%x,100%y)

STR2 is partly visible but the scroll function doesn't work

Where is the problem? Thanks!
 

derez

Expert
Licensed User
Longtime User
The height in the scrollview initialization which is the size of the scrollview's panel can be greater then the size of the view itself. If is not - the panel will not scroll.
So, change
ScrollViewTesto.Initialize(60%y) to
ScrollViewTesto.Initialize(200%y)
and see if it scrolls.
 
Upvote 0

GaNdAlF89

Active Member
Licensed User
Longtime User
Thanks for all!! :)
I've solved with adding this:
B4X:
Dim suTmp As StringUtils
LabelTesto.Height = suTmp.MeasureMultilineTextHeight(LabelTesto,STR2)
ScrollViewTesto.Panel.Height = LabelTesto.Height
 
Upvote 0
Top