Android Question Problem with rotated customListView on Android 9

Discussion in 'Android Questions' started by FrankBerra, Jun 18, 2019.

  1. FrankBerra

    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)
     

    Attached Files:

  2. Erel

    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.
     
  3. FrankBerra

    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/t...m-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)
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    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.
     
  5. FrankBerra

    FrankBerra Active Member Licensed User

  6. Erel

    Erel Administrator Staff Member Licensed User

    I don't think so.
     
  7. FrankBerra

    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:

    Code:
    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!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice