Xamarin.forms: [Bug] Scrolling issues in Android 9.0 Pie

Created on 15 Aug 2019  路  17Comments  路  Source: xamarin/Xamarin.Forms

Description

When Android phone having version 9.0 Pie, the scrolling is stuck and scroll in the wrong direction.

Steps to Reproduce

  1. Create ListView with 50+ items (more than one screen)
  2. Set Rotation of ListView to 180
  3. Set Rotation of ItemTemplate to 180
  4. Swipe fast ( up -> buttom) , that request Fling action

Expected Behavior

Typical behavior of scrolling

Actual Behavior

Scroll direction changed to 180 degrees

Basic Information

  • Version with issue:
    Xamarin.Forms v4.1.0
  • Last known good version:
    Any
  • IDE:
    Visual Studio Community 19

Reproduction Code

ChatUIXForms

listview 4 high impact Android bug

Most helpful comment

after a lot of work I could solve the problem.
I Use CollectionView with custom rendrer in android:

[assembly: ExportRenderer(typeof(CollectionView), typeof(ExCollectionViewRenderer))]

namespace Healx.Droid.CustomRenderer
{
    public class ExCollectionViewRenderer : CollectionViewRenderer
    {
        public ExCollectionViewRenderer(Context context) : base(context)
        {

        }
        private int dy = 0;
        public override void OnScrolled(int dx, int dy)
        {
            this.dy = dy;

            base.OnScrolled(dx, dy);
        }
        public override bool Fling(int velocityX, int velocityY)
        {

            return base.Fling(velocityX, Math.Abs(velocityY) * Math.Sign(dy));

        }

        protected override void OnElementChanged(ElementChangedEventArgs<ItemsView> elementChangedEvent)
        {

            base.OnElementChanged(elementChangedEvent);
        }
    }

}

All 17 comments

@VasenevEA have you tried this with CollectionView?

@VasenevEA have you tried this with CollectionView?

Yes. Same behavior

any changes pending?

@paleicikas do you know if it's possible to create a workaraound while this issue is not fixed?

I have this problem too,

I've got the same issue too. Are there any workarounds?

Any updates on issue? This issue makes collection view unusable on some devices with specific android/vendor combination (i.e. samsung/android 9)

Any workarounds?

Hi from the same same boat, if you have any workarounds for Android while it's not fixed please share any ideas! Maybe some custom renderer with custom velocity tracker or something..

Hey a very diagnostic sign, could help debugging - the scroll bar position!

Layout:
ListView
Rotation="180" FlowDirection="RightToLeft",
Cell Template
Rotation="180" FlowDirection="LeftToRight"

Result:
case 1:
nice chat list with scroll bar on the right side.

case 2 - android 9 bug:
nice(?) chat list, but.. scroll bar on the left side, and while scroll works as intended when dragging, when you swipe it scrolls to the wrong direction.

I dropped the idea of moving with rotation.In my case I am trying to implement chat UI. I implemented the chat according to this repo (https://github.com/jamesmontemagno/app-monkeychat ). There is no need to rotate the list

Thanks, unfortunately didn't solve what the rotated list does:

  • with list with FillAndExpand and rotated 180 messages start to appear in bottom of the screen, then they are filling the blank space from bottom to top as long as more messages are incoming. With a non rotated list one would have to resize and reposition the list to obtain such effect what would bring more visual artifacts among different os and devices. When it's required by design would prefer to use rotation.. :P

any updates?

after a lot of work I could solve the problem.
I Use CollectionView with custom rendrer in android:

[assembly: ExportRenderer(typeof(CollectionView), typeof(ExCollectionViewRenderer))]

namespace Healx.Droid.CustomRenderer
{
    public class ExCollectionViewRenderer : CollectionViewRenderer
    {
        public ExCollectionViewRenderer(Context context) : base(context)
        {

        }
        private int dy = 0;
        public override void OnScrolled(int dx, int dy)
        {
            this.dy = dy;

            base.OnScrolled(dx, dy);
        }
        public override bool Fling(int velocityX, int velocityY)
        {

            return base.Fling(velocityX, Math.Abs(velocityY) * Math.Sign(dy));

        }

        protected override void OnElementChanged(ElementChangedEventArgs<ItemsView> elementChangedEvent)
        {

            base.OnElementChanged(elementChangedEvent);
        }
    }

}

Can confirm that fix above works

I have this problem too.
Running on Android 9.0 the same behavior.

Was this page helpful?
0 / 5 - 0 ratings