Bug? ScrollView.Panel.Height

Midimaster

Active Member
Licensed User
I needed one hour to find out, what is the reason for a strange behavior in my code. Now I think I can prove that this is a bug:

I use the Scrollview to offer a variing number of objects. Of course the Innerheight() of the Scrollview should exactly fit the object. So I change ScrollView.Panel.Height after adding or removing objects. But the Innerheight is not updates and keep as it was before. Sometimes bigger as needed, sometimes to small.

This is a minimal example that shows the behavior:


B4X:
Sub Globals
    Private Button1,Button2 As Button   
    Private ScrollView1 As ScrollView
    Private Labels(15) As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("layout1")
    ScrollView1.Panel.Color=Colors.Red
    For i=0 To 14
        Labels(i).Initialize("press")
        Labels(i).Color=Colors.Gray
        ScrollView1.Panel.AddView(Labels(i),0,50dip*i,200dip,45dip)       
    Next
End Sub

Sub Button1_Click
    ScrollView1.Panel.Height=1000
    ScrollView1.Height=600
    Log("click smaller")   
End Sub

Sub Button2_Click
    ScrollView1.Panel.Height=3000
    ScrollView1.Height=600
    Log("click bigger")
End Sub

The first pressing of the button will work. You see the Scrollview shrinking to 600 and, depending on the button you pressed, the Innerheight() will change to 1000 or 3000. But... nothing happens with Innerheight() after pressing the second button.

If you change the code to....
B4X:
Sub Button1_Click
    ScrollView1.Panel.Height=1000
    ScrollView1.Height=601  '<------also change something else
    Log("click smaller")   
End Sub

Sub Button2_Click
    ScrollView1.Panel.Height=3000
    ScrollView1.Height=599  '<------also change something else

    Log("click bigger")
End Sub

...everything will work as expected. That shows, that the changing of the Innerheight() does not start a updating of the view. But if a parameter of theScrollView changes (... or any parameter of one of the inner objects) also the Innerheight will be updates.
 

Midimaster

Active Member
Licensed User
Thanks Erel. I did not read anywhere, that this is a wellknown issue. The manuals should contain advises to such behaviors. It costs a lot of time for beginners to find out all these things by "try and error" I need one hour and a extra new demo project to prove that its not my bug.

And... yesterday I really tried to start ith xCustonListView. But for a Android-Beginner it is not possible to understand how to start with Custom-Views. The manual is a terrible mixture of "class" explanation and "all features" of custom views. With sideviews to "of course you have installed already... " and anroid internals.

So I gave up!

You should really start writing a manual with an easy to understand minimal app and a step by step description how to use ONLY CustomListView for the first time.
 

Midimaster

Active Member
Licensed User
thank you Erel. I watched the video and now I see it is very easy to use the CustomListView(). I was very confused with some (perhaps out-of-date) tutorials I found here.
 
Top