Skip to content

[Android] Fixed the ScrollbarVisibility issues#27613

Merged
mattleibow merged 3 commits intodotnet:mainfrom
Ahamed-Ali:fix-24894
Feb 28, 2025
Merged

[Android] Fixed the ScrollbarVisibility issues#27613
mattleibow merged 3 commits intodotnet:mainfrom
Ahamed-Ali:fix-24894

Conversation

@Ahamed-Ali
Copy link
Copy Markdown
Contributor

@Ahamed-Ali Ahamed-Ali commented Feb 6, 2025

Root Cause of the issue

Initial Case:

  • The ScrollBarFadingEnabled property is always set to true even when ScrollBarVisibility is set to Always. As a result, the scrollbar remains hidden in the Always visibility mode.

Dynamic Case:

  • After fixing the initial issue, it was observed that when the visibility mode changes dynamically from Default to Always, the scrollbar does not display correctly. Although ScrollBarFadingEnabled is updated properly, the scrollbar remains hidden because the HandleScrollBarVisibilityChange method processes both its true and false states, and RequestLayout is not called.

  • In the native Android itself, dynamic changes to ScrollbarFadingEnabled are not properly reflected in the UI until the view is scrolled. Calling RequestLayout when dynamic changes occur ensures that the native UI updates correctly.

Description of Change

Initial Case:

  • Setting ScrollBarFadingEnabled based on ScrollBarVisibility resolves the issue.

Dynamic Case:

  • Removing the HandleScrollBarVisibilityChange method which was responsible for awakening the scrollbars and adding a call to RequestLayoutIfNeeded efficiently resolves the dynamic issues and ensures that the UI updates properly. With RequestLayoutIfNeeded, calling AwakenScrollBars may no longer be necessary.

Issues Fixed

Fixes #24894
Fixes #12760

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Screenshot

VerticalScrollbarVisibility

Before Issue Fix After Issue Fix
VerticalScrollBarIssue.mov
VerticalScrollbarFix.mov

HorizontalScrollbarVisibility

Before Issue Fix After Issue Fix
HorizontalScrollbarIssue.mov
HorizontalScrollbarFix.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Feb 6, 2025
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Hey there @Ahamed-Ali! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@karthikraja-arumugam karthikraja-arumugam added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Feb 7, 2025
@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@Ahamed-Ali Ahamed-Ali marked this pull request as ready for review February 7, 2025 12:27
Copilot AI review requested due to automatic review settings February 7, 2025 12:27
@Ahamed-Ali Ahamed-Ali requested a review from a team as a code owner February 7, 2025 12:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/Core/src/Platform/Android/MauiScrollView.cs:72

  • [nitpick] The variable name _verticalScrollVisibility should not be prefixed with an underscore as it is not a private field. Consider renaming it to verticalScrollVisibility.
ScrollBarVisibility _verticalScrollVisibility = scrollBarVisibility;

@PureWeen PureWeen added this to the .NET 9 SR5 milestone Feb 7, 2025
@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@mattleibow mattleibow moved this from Ready To Review to Changes Requested in MAUI SDK Ongoing Feb 27, 2025
Copy link
Copy Markdown
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to pick a side, so changes requested it is.

The code is good, but I worry about that removed method and the crash comment.

@github-project-automation github-project-automation bot moved this from Changes Requested to Approved in MAUI SDK Ongoing Feb 28, 2025
@mattleibow mattleibow merged commit 196a1d6 into dotnet:main Feb 28, 2025
123 of 125 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Feb 28, 2025
tj-devel709 pushed a commit that referenced this pull request Mar 3, 2025
* [Android] Fixed the ScrollbarVisibility issues

* Committed the review changes and added additional test

* Renamed Variable
bhavanesh2001 pushed a commit to bhavanesh2001/maui that referenced this pull request Mar 7, 2025
* [Android] Fixed the ScrollbarVisibility issues

* Committed the review changes and added additional test

* Renamed Variable
@github-actions github-actions bot locked and limited conversation to collaborators Mar 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-scrollview ScrollView community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Vertical ScrollBar is not visible until scrolled in Android platform. ScrollBarVisibility "Always" is not consistent.

6 participants