Android Question ScrollView Not Redrawing after Panel.Height is adjusted

cooperlegend

Active Member
Licensed User
B4X:
    If Common.PlayerId5 = 0 AND Common.PlayerId6 = 0 AND Common.PlayerId7 = 0 AND Common.PlayerId8 = 0 Then
        scrollStarts.Panel.Height = scrollStarts.Height ' Set to not scroll for extra players.
    Else
        scrollStarts.Panel.Height = scrollStarts.Height * 2 ' Set to scroll for extra players.
    End If
I simply want to adjust the scrolling area depending on the number of "players" to be shown.

What I have found is that once the Panel.Height has been set that it does not update it a second time UNLESS you move to another form or open a new panel or something similar, than at that point it will redraw once called up again.

Tried all sorts of things including :-
doevents
invalidate
changing color parameter
changing panel.Width
None of the above made any difference.

Any ideas?
 
Last edited:

cooperlegend

Active Member
Licensed User
Thanks for the reply, But as stated above, DoEvents didn't resolve this issue.

Any other ideas anyone?
 
Last edited:

Erel

Administrator
Staff member
Licensed User
Try this code:
B4X:
Sub lblFour_Click
   scrollStarts.Panel.Height = scrollStarts.Height ' Set to scroll for extra players.
   Dim jo As JavaObject = scrollStarts.Panel
   jo.RunMethod("requestLayout", Null)
End Sub

Sub lblEight_Click
   scrollStarts.Panel.Height = scrollStarts.Height * 2 ' Set to scroll for extra players.
   Dim jo As JavaObject = scrollStarts.Panel
   jo.RunMethod("requestLayout", Null)
End Sub
 

Mark Hollingworth

Member
Licensed User
I have just hit the same issue where my scrollview panel would not update its height.

I am not sure if this is caused because the scrollview was added using the designer but I found a different solution.

I am adding items to the scrollview using a sub routine called in Activity_Create, inside my sub routine is where I am adding items and was trying to update the scrollview.panel.height but nothing would work to adjust the size so I took the scrollview.panel.height out of my sub routine and added it directly to the Activity_Create and it started working as expected and updated the height correctly everytime I fire the activity. As soon as I move scrollview.panel.height back into my sub it stops working again and just uses the default set in the designer.

Strangely it does seem to work in other parts of my app but they are not as dynamic as the one I had issues with. :confused:

Not sure if this is a bug but thought I would mention it :)
 

cooperlegend

Active Member
Licensed User
How strange !

just checked my code, I add the items Activity_Create, yet mine needed Erels code to work ....
 
Top