Android Question Problem with rotated customListView on Android 9

FrankBerra

Active Member
Licensed User
Hello Forum

I my app i placed a customListView rotated by 180 degrees. Everything worked fine until i upgraded my device to Android 9.
Now scrollong that CLV became problematic: if you drive the scrollview by the finger it works, but as soon as you lift up the finger the scrollview starts to became crazy scrolling to the opposite direction.

This behaviour happens only on android 9.
I haven't found too much informations about (just this link: https://github.com/xamarin/Xamarin.Forms/issues/6321)

Anyone that experienced the same problem and can suggest a solution?

(I attach an example project with the rotated CLV)
 

Attachments

Erel

Administrator
Staff member
Licensed User
Seems to work fine here on Android 9.

1. Why aren't you using xCustomListView library? It is a mistake to use the class.

2. Why not rotate each item separately? Will probably work better.
 

FrankBerra

Active Member
Licensed User
1) I am using the class because i need to add some other codes to xCLV (for example i found here on the forum a modified version with selection mode, i added a sub to resize an item and shift the others intead of removing and adding it back, etc)

2) I created a chat application. When i scroll back messages and i reach the top of scrollview i add old messages to the top. After i add, for example, one message to the top i scroll down programmatically to the original top item. If i add dozens of messages to the top i can see a ugly "bouncing" effect on the scrollview items. So i created a workaround by rotating the CLV so when i scroll to the top of CLV in the reality i scrolled to the bottom to the CLV and i add old messages to the bottom of CLV and in this way i don't need to jump programmatically to the original top item.
By rotating CLV by 180 i need of course to rotate all the items too so in this way all items appear straight on the screen.
(https://www.b4x.com/android/forum/threads/xui-customlistview-problem-with-getscrollviewoffset.95845/#post-605683)


Here the link to video about the strange behaviour i have on my android 9 device: https://photos.app.goo.gl/YRMXnfEQgHAkNTLv5
(Sorry i can't upload it here on the forum due to a size limitation)
 

Erel

Administrator
Staff member
Licensed User
for example i found here on the forum a modified version with selection mode, i added a sub to resize an item and shift the others intead of removing and adding it back, etc
Resizing items is supported in xCLV. You can also implement different selection models without modifying the code.

About the rotation, this is handled by the OS so I don't think that there is much that you can do.
 

FrankBerra

Active Member
Licensed User
I tryed to handle the scrollview with Gesture Detector library. In this way, at least, i disable the "momentum".
Here following the code i used if anyone is facing the same problem:

B4X:
Dim p As Phone
If p.SdkVersion == 28 Then 
   GD.SetOnGestureListener(CLV.sv, "GD")
End If

'--------------------

SubGD_onTouch(Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
   Return True 'True = Handle this touch event, False = Ignore it
End Sub

Sub GD_onScroll(distanceX As Float, distanceY As Float, MotionEvent1 As Object, MotionEvent2 As Object)
   Dim scroller As ScrollView = CLV.sv
   scroller.ScrollPosition = scroller.ScrollPosition + distanceY
End Sub

Sub GD_onFling(velocityX As Float, velocityY As Float, MotionEvent1 As Object, MotionEvent2 As Object)
   Dim scroller As ScrollView = CLV.sv
   scroller.ScrollPosition = scroller.ScrollPosition + velocityY / 5  'Not nice but better than nothing.
End Sub
Suggestions for improvements are wellcome!
 
Top