Bug? ScrollView Panel resize + scroll bug

zity

Member
Licensed User
Longtime User
It seems like it's quite an old issue, but it's still not solved and I can't get a Scrollview with EditTexts scrolling reliably when the Keyboard opens.

Attached is a small demo project with the current best workaround:
After resizing the ScrollViews inner Panel, you need to "requestLayout" + Sleep, but this is also not reliable and adds an unnecessary delay of a random length.

I think the main problem is that we don't know when the resizing of the inner Panel has actually finished, so that we can scroll after that.

Some stackoverflow answers suggests that you need to wait for the "onGlobalLayout" event and scroll only after that, which seems to make sense.

@Erel, Could you look at it and implement maybe a panel resize + scroll function that waits for the resize to finish?
 

Attachments

  • sctest.zip
    8.5 KB · Views: 29

Erel

B4X founder
Staff member
Licensed User
Longtime User
There is no bug here. This is the behavior of the OS.
If you like to implement this listener then it can be done with JavaObject. Start a new thread if you need assistance.

I recommend you to choose a different approach and increase the inner panel height so it will include the extra length for the keyboard. This way you will never need to resize the panel.
 

zity

Member
Licensed User
Longtime User
I recommend you to choose a different approach and increase the inner panel height so it will include the extra length for the keyboard. This way you will never need to resize the panel.
I am actually increasing the inner panel height!
Please check the above project in which I have isolated the issue.

The problem is that even after resizing the inner panel, it's not possible to scroll to the bottom of the scrollview until that resize has actually happened.
And because we don't know when that is, there's a need for a random amount of sleep.

Just to make sure, I have also tested the CLV keyboard handling example and it also can't scroll to the bottom item after resizing.
Attached a modified CLV example as well:
- If you click the edittext, the CLV will try to scroll to the bottom element - it doesn't work
- If you click the button, it adds a new CLV item and tries to scroll to it - it doesn't work

I still think "extending a scrollview and then scrolling to the bottom" or in CLV terms "adding an item and scrolling to it" should be handled by the core libraries and considered a bug, but if not, then I can go with the JavaObject route.
 

Attachments

  • ListAndKeyboard-Scroll.zip
    11.1 KB · Views: 27

Alexander Stolte

Expert
Licensed User
Longtime User
I still think "extending a scrollview and then scrolling to the bottom" or in CLV terms "adding an item and scrolling to it" should be handled by the core libraries and considered a bug
Why? How is the library supposed to know when you are done adding? It's just as well that the core library does it the way it has always done it.
 
Top