Android Question ScrollView and KeyUP

peacemaker

Expert
Licensed User
HI, All

I'm scrolling the ScrollView with a picture by the keyboard D-pad (only D-pad is available on the target device).

Using activity keys is OK:
B4X:
Sub Activity_KeyUp (KeyCode As Int) As Boolean

But i need to scroll by the exact step, but this step is OK only for the first button press - at any next key pressing - the scrolling is done multiply, with some big step, and
B4X:
Sub sw_ScrollChanged(Position As Int)
fired many times. So - too long scrolling - but why ?

I have read about some problem with scrolling, and using:
B4X:
sw.ScrollToNow (sw.ScrollPosition + d)
DoEvents
sw.ScrollToNow (sw.ScrollPosition + d)

but it's not the reason of the big step of the key press.
If to scroll NOT by key pressing, but some tapping - all works fine, scroll to the needed step.
Any help ?
 

peacemaker

Expert
Licensed User
Check how many times Activity_KeyUp is raised
Checked, sure - single time.
Log is like:

B4X:
KeyPressed=20
KeyUpped=20
h=576
ScrollChanged to =1
ScrollChanged to =22
ScrollChanged to =22
ScrollChanged to =56
ScrollChanged to =56
ScrollChanged to =73
ScrollChanged to =73
ScrollChanged to =80
ScrollChanged to =80
KeyUpped=20
ScrollChanged to =86
ScrollChanged to =86
ScrollChanged to =89
ScrollChanged to =89
ScrollChanged to =90
ScrollChanged to =90
ScrollChanged to =92
ScrollChanged to =92
ScrollChanged to =93
ScrollChanged to =93
PicFile=Day1_list03.gif
scrolled_to=110
ScrollChanged to =110
ScrollChanged to =130
ScrollChanged to =130
ScrollChanged to =163
ScrollChanged to =163
ScrollChanged to =173
ScrollChanged to =173
ScrollChanged to =187
ScrollChanged to =187
KeyUpped=20
ScrollChanged to =194
ScrollChanged to =194

I mean that ScrollChanged is fired many times after SINGLE key press and up. But if to change ScrollPosition not by the keyboard, by tapping some screen buttons - no problem - just single correct scrolling:

B4X:
ScrollChanged to =304
PicFile=Day1_list05.gif
scrolled_to=321
ScrollChanged to =321
PicFile=Day1_list05.gif
scrolled_to=338
ScrollChanged to =338
PicFile=Day1_list05.gif
scrolled_to=355
ScrollChanged to =355
PicFile=Day1_list05.gif
scrolled_to=372
ScrollChanged to =372
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
It looks like scrolling started _before_ changing position code execution, and after - also...
Maybe is ScrollView also controllable by Activity key listener independently ?
 
Upvote 0
Top