Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] [Android] Vertical scroll indicator appears on Label with limited vertical size inside ScrollView #9591

Closed
stephanpalmer opened this issue Feb 14, 2020 · 5 comments
Labels
4.4.0 regression on 4.4.0 a/label a/scrollview e/2 🕑 2 i/regression in-progress This issue has an associated pull request that may resolve it! p/Android t/bug 🐛

Comments

@stephanpalmer
Copy link

stephanpalmer commented Feb 14, 2020

Description

After upgrade to XF 4.4.0.991640 on Android, vertical scroll indicators appear on labels with limited vertical size, when the content does not fit into the label. The attached example uses an absolute layout and a HeightRequest in the label to achieve the scenario. A similar behavior can e.g. be observed in ListView cells (ListView without uneven row setting), where the height is limited as well.

Steps to Reproduce

  1. Create a project with Xamarin.Forms 4.4.0.991640
  2. Create a label inside a scroll view, and make sure the label has a height limit which is too small for the text content.
  3. Display this setup on a page.

Expected Behavior

No scroll bar / scroll indicator appears.

Actual Behavior

A scroll bar / scroll indicator appears for a short time after the label is being presented.

Basic Information

  • Version with issue: 4.4.0.991640
  • Last known good version: 4.3.0.991221
  • IDE: Visual Studio 8.3.11.1, Xamarin.Android 10.0.6.2
  • Platform Target Frameworks:
    • Android: Android 9.0 / API Level 28
  • Android Support Library Version: 28.0.0.3
  • Nuget Packages: Xamarin.Forms 4.4.0.991640, Xamarin.Android.Support.Core.Utils 28.0.0.3
  • Affected Devices: We've reproduced this behavior on a Samsing Galaxy S7 with Android 7.0, Google Nexus 5 with Android 6.0.1, Google Pixel with Android 10, and a Pixel 2 simulator with Android 9.

Screenshots

labelscrollbar

Reproduction Link

Minimal reproduction example: labelscrollbar.zip

Workaround

It seems that this issue is caused by #8090, as mentioned here. We've found two workarounds, which we used for labels and text entries, where we had a similar problem.

Workaround Option 1: Disable scroll bars in custom renderer

[assembly: ExportRenderer(typeof(Label), typeof(CustomLabelRenderer))]

public class CustomLabelRenderer : LabelRenderer
{
    public CustomLabelRenderer(Context context) : base(context)
    {
    }

    protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
    {
        base.OnElementChanged(e);
        Control.VerticalScrollBarEnabled = false;
    }
}

Disable vertical and/or horizontal scrollbars as needed. We've had a similar problem with Entry views, where a horizontal scrollbar appeared.

Workaround Option 2: Use legacy constructor for renderer

This workaround has the disadvantage of using a deprecated constructor!

[assembly: ExportRenderer(typeof(Label), typeof(CustomLabelRenderer))]

public class CustomLabelRenderer : LabelRenderer
{
    public CustomLabelRenderer() : base()
    {
    }
}

This workaround is based on the workaround for #9019 by @dminta (see here). It is based on the fact that the changes of #8090 only apply to the renderer constructor with Context as parameter. The passed context is wrapped with a style which enables vertical and horizontal scroll bars. I assume that Xamarin.Forms passes this wrapped context to child renderers of the scroll view renderer.

In contrast to @dminta's workaround, it's not the ScrollViewRenderer which is replaced in this workaround, but the LabelRenderer. When replacing the scroll view renderer, the bug fixed by #8090 reappears - namely that the scroll bar does not appear for a scroll view. By replacing only the label renderer, the scroll bar of the scroll view still works.

@stephanpalmer stephanpalmer added s/unverified New report that has yet to be verified t/bug 🐛 labels Feb 14, 2020
@stephanpalmer
Copy link
Author

This issue is very similar to #9019, but affects Labels instead of Buttons.

@leo-mck
Copy link

leo-mck commented Feb 16, 2020

Looks like #9423 also.

@stephanpalmer
Copy link
Author

I've extended the bug description with possible workarounds.

@stephanpalmer
Copy link
Author

It seems that this issue caused by #8090. There are other views which are affected. E.g. we had a similar problems with the Entry view, where horizontal scrollbars appeared.

I've not created a new issue for the entry class, because I assume it would make sense to consolidate the different bug reports for this problem in a single Github issue.

@velocitysystems
Copy link
Contributor

velocitysystems commented Apr 24, 2020

@samhouts Do we possibly have an ETA for this fix? This regression really needs to be addressed immediately. Especially, given it also affects other controlled such as Entry which are widely used.

@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Apr 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4.4.0 regression on 4.4.0 a/label a/scrollview e/2 🕑 2 i/regression in-progress This issue has an associated pull request that may resolve it! p/Android t/bug 🐛
Projects
None yet
Development

No branches or pull requests

4 participants