Bug? Changing dimensions of scrollview inner panel doesn't trigger a redraw

stevel05

Expert
Licensed User
Longtime User
This may be something to do with the way I am using it, but:

If the height or width of the inner panel is changed on a scrollview, it is not redrawn. Changing the color does force a redraw. This is even with the commented invalidate statements.

The height of the Label that is added to the panel has a height of -2 (Wrap_Content) given in the designer. An example project is attached.

This is a sub from an app I am working on. Uncomment the 'svFLSHelp.Panel.Color = Colors.Transparent line and it redraws the panel and it's and contents.

B4X:
Sub btnFLSHelp_Click
    If lblFLSHelp.Text = "" Then

        'Initialize the scroll view
        svFLSHelp.Initialize(500)
        'Add the scroll view to it's parent panel
        pnlFLS.AddView(svFLSHelp,2Dip,2Dip,pnlFLS.Width - 4dip,pnlFLS.Height - 4Dip)
      
        'Remove the label (defined in designer) from it's current parent(activity)
        lblFLSHelp.RemoveView
        'Add the label to the panel      
        svFLSHelp.Panel.AddView(lblFLSHelp,0,0,svFLSHelp.Width,lblFLSHelp.Height)
      
        'Set some padding for the label
        Dim lblJO As JavaObject = lblFLSHelp
        lblJO.RunMethod("setPadding",Array(5Dip,5Dip,5Dip,5Dip))
      
        'Load the help text to the label
        Dim Text As String = File.ReadString(File.DirAssets,"flshelp.txt")
        lblFLSHelp.Text = Text
      
        'make the label visible so we can measure it
        lblFLSHelp.Visible = True
      
        'Update the views
        svFLSHelp.Invalidate
        DoEvents
      
        'Measure the label (height is originally set to -2 as we don't know how much text there will be)
        Dim lblHeight As Int = lblJO.RunMethod("getHeight",Null)
        Log(lblHeight)
      
        'Change something else except the dimensions so the view updates
        'svFLSHelp.Panel.Color = Colors.Transparent
      
      
        'Set the inner height of the scroll view
        svFLSHelp.Panel.Height = lblHeight
      
        'Check it has the correct height
        Log(svFLSHelp.Panel.Height)
      
        'Invalidate the scrollview panel
'        svFLSHelp.Panel.Invalidate
'        DoEvents
'        'Invalidate the scrollview
'        svFLSHelp.Invalidate
'        DoEvents
    End If
  
    'If it's already initialised, just make it visible
    svFLSHelp.Visible = True
End Sub
 

Attachments

  • ScrollViewUpdateTest.zip
    8.6 KB · Views: 217
Last edited:

stevel05

Expert
Licensed User
Longtime User
Thanks Erel. That did it.
 
Top