xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.87k forks source link

[Bug] Scroll Bars appear on controls inside a CollectionView #8626

Closed johnallan78 closed 4 years ago

johnallan78 commented 4 years ago

Description

When I open a Time Picker inside a Collection View on Android, there are vertical scroll bars that appear in the dialog. I'm using a Holo theme and have attached a small repo to reproduce this. It's not a breaking change and has no effect on functionality, but they are a bit ugly and distracting. They don't appear if you are using ListView. For the purposes of this reproduction I have used a Time Picker control, but I have seen these scroll bars appear in Editor controls too.

Steps to Reproduce

  1. Click on any Time Picker and you should see the scroll bars briefly appear.

Expected Behavior

No scroll bars to appear, as was the case when using ListView

Actual Behavior

Basic Information

Screenshots

Android Scroll Bars Screenshot

Reproduction Link

https://github.com/johnallan78/CollectionViewTest

johnallan78 commented 4 years ago

Just to clarify, this doesn't happen, or at least I can't reproduce the bug, when the control is not in a CollectionView

jfversluis commented 4 years ago

Confirmed this behavior. When you put a TimePicker outside the CollectionView you won't see the scrollbars flash while they do when opened from inside the CollectionView. Also happens with other scrollable controls.

SoaringChris commented 4 years ago

Also experiencing random scroll bars appearing in on labels within a grid as well as SegmentedControls created with Forms9Patch when placed in collection views. This was not an issue in older versions of Xamarin

iamlawrencev commented 4 years ago

Can confirm this bug. My case is that I have in controls in the Header of my CollectionView. It then displays a small scrollbar on the upper-right of the view similar to the screenshot above.

moustafashaban commented 4 years ago

this one is really annoying, I had to add Control.VerticalScrollBarEnabled = false; in the LabelRenderer to solve it, but I still see it in other places, especially with some controls inside a scroll viewer

JKennedy24 commented 4 years ago

heres a workaround renderer for anyone who wants a quick workaround:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using MyApp.Droid.CustomRenderers.Controls;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Xamarin.Forms.Platform.Android.FastRenderers;

//workaround for this issue: https://github.com/xamarin/Xamarin.Forms/issues/8626
//also think there may be an issue on labels in general

[assembly: ExportRenderer(typeof(Label), typeof(MyAppLabelRenderer ))]
namespace MyApp.Droid.CustomRenderers.Controls
{
    class MyAppLabelRenderer : Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer
    {
        public MyAppLabelRenderer (Context context) : base(context)
        {

        }

        protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
        {
            base.OnElementChanged(e);

            if (Control == null || e.NewElement == null)
            {
                return;
            }
            Control.VerticalScrollBarEnabled = false;
        }
    }
}
aktxyz commented 4 years ago

whew ... thought I was seeing things with these random scroll bars !! looks like will be fixed soon

Edgaras91 commented 4 years ago

I am getting this issue with ScrollViews too! Buttons and checkboxes inside the scroll view "gain" a scroll bar, which is only visible on page load time (same time as scroll bar for scroll view appears). Controls are not actually scrollable. Everything scrolls in the scroll view as intended.