Xamarin.forms: [Bug] [Android] Vertical Scroll Bars appear on Button inside ScrollView with custom Style

Created on 26 Dec 2019  路  6Comments  路  Source: xamarin/Xamarin.Forms

Description

After upgrade to XF 4.4.0.991265 on Android
Vertical Scroll Bars appear on Button inside ScrollView with custom Style (font)

Steps to Reproduce

  1. Create new project with Xamarin.Forms 4.2.0.709249
  2. Add ScrollView with buttons and custom style with font
  3. Upgrade to Xamarin.Forms 4.4.0.991265

Expected Behavior

Buttons without vertical scroll bar inside

Actual Behavior

Vertical Scroll Bars appear on Buttons (short time)

Basic Information

  • Version with issue: 4.4.0.991265
  • Last known good version: 4.2.0.709249
  • IDE: Visual Studio Community 2019 for Mac Version 8.3.11 (build 1)
  • Platform Target Frameworks:

    • Android: Android 9.0

  • Android Support Library Version: Xamarin.Android.Support.Core.Utils 28.0.0.3
  • Nuget Packages: Xamarin.Essentials 1.3.1
  • Affected Devices: Samsung S8

    Screenshots

issue

Screenshot_20191226-144209-2

Reproduction Link

https://github.com/kuzub/ButtonWithScrollViewIssue

4.4.0 2 regression in-progress Android bug

Most helpful comment

This bug was introduced with changes for issue #8090.

Temporary workaround:

  • replace ScrollView with empty CustomScrollView:

public class CustomScrollView : ScrollView
{
}

  • create empty CustomScrollViewRenderer for Android:

[assembly: ExportRenderer(typeof(CustomScrollView), typeof(CustomScrollViewRenderer))]

...

public class CustomScrollViewRenderer : ScrollViewRenderer
{
}

It uses Forms.Context instead of ContextThemeWrapper(context, Resource.Style.NestedScrollBarStyle).

All 6 comments

If add empty ButtonRenderer -> Issue will fixed
public class FixButtonIssueRenderer : ButtonRenderer
{
public FixButtonIssueRenderer(Context context) : base(context)
{
}
}

Seems to have happened between 4.3.0 and 4.4.0-pre1.

This bug was introduced with changes for issue #8090.

Temporary workaround:

  • replace ScrollView with empty CustomScrollView:

public class CustomScrollView : ScrollView
{
}

  • create empty CustomScrollViewRenderer for Android:

[assembly: ExportRenderer(typeof(CustomScrollView), typeof(CustomScrollViewRenderer))]

...

public class CustomScrollViewRenderer : ScrollViewRenderer
{
}

It uses Forms.Context instead of ContextThemeWrapper(context, Resource.Style.NestedScrollBarStyle).

I'm using a padding of -10 to work around that problem.

<Style x:Key="PrimaryButtonStyle" TargetType="Button">
        <Setter Property="Padding" Value="-10" />
</Style>

I was using some padding on Android already to deal with the fact that the text gets clipped when the size of the button is smaller then what is need to draw the text (Only on Android)

This bug was introduced with changes for issue #8090.

Temporary workaround

it helped, but not everywhere (but it's better than nothing). Used through the effects of disabling scrolling for labels

Did the ScrollBars disappear completely? I got a FlexLayout inside a ScrollView with Xamarin.Forms 4.6 and ScrollBars are not showing up. Before updating I had Xamarin.Forms 4.4 the ScrollBars are there.

Was this page helpful?
0 / 5 - 0 ratings