KEMBAR78
[Android] Set FillViewport to true to MauiHorizontalScrollView by kubaflo · Pull Request #26904 · dotnet/maui · GitHub
Skip to content

Conversation

kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Jan 1, 2025

Issues Fixed

Fixes #25462
Fixes #25655
Fixes #9446

<VerticalStackLayout>
        <ScrollView Orientation="Horizontal"
                        Grid.Row="0"
                        HeightRequest="120"
                        HorizontalOptions="Fill"
                        BackgroundColor="Green">
                <HorizontalStackLayout
                        HorizontalOptions="Fill"
                        BackgroundColor="Pink">
                        <Label Text="Hello"/>
                </HorizontalStackLayout>
        </ScrollView>

        <ScrollView Grid.Row="2"
                        VerticalOptions="Fill"
                        Orientation="Vertical"
                        BackgroundColor="Green"
                        HorizontalOptions="Fill">
                <StackLayout HorizontalOptions="Fill"
                                VerticalOptions="Center"
                                BackgroundColor="Red">
                        <Label Text="Hello"/>
                </StackLayout>
        </ScrollView>
</VerticalStackLayout>
Before After

@kubaflo kubaflo requested a review from a team as a code owner January 1, 2025 23:55
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jan 1, 2025
@jfversluis
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@rmarinho
Copy link
Member

rmarinho commented Jan 3, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@karthikraja-arumugam
Copy link
Contributor

These changes also resolve the issue #9446.

@kubaflo
Copy link
Contributor Author

kubaflo commented Mar 2, 2025

These changes also resolve the issue #9446.

Thanks!

@jfversluis jfversluis added this to the .NET 9 SR5 milestone Mar 3, 2025
jsuarezruiz
jsuarezruiz previously approved these changes Mar 3, 2025
@PureWeen PureWeen moved this from Todo to Approved in MAUI SDK Ongoing Mar 3, 2025
@PureWeen
Copy link
Member

PureWeen commented Mar 3, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

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

Looks like this one needs a new screenshot
LayoutInHorizontalScrollViewShouldExpand

@github-project-automation github-project-automation bot moved this from Approved to Changes Requested in MAUI SDK Ongoing Mar 5, 2025
@kubaflo kubaflo force-pushed the StackLayout-inside-Scrollview-with-horizontal-orientation-not-expanding branch from 654aa79 to 03cf6de Compare March 5, 2025 18:40
@kubaflo
Copy link
Contributor Author

kubaflo commented Mar 5, 2025

Looks like this one needs a new screenshot LayoutInHorizontalScrollViewShouldExpand

done

@PureWeen PureWeen modified the milestones: .NET 9 SR5, .NET 9 SR6 Mar 7, 2025
@PureWeen PureWeen moved this from Changes Requested to Ready To Review in MAUI SDK Ongoing Mar 23, 2025
@PureWeen PureWeen modified the milestones: .NET 9 SR6, .NET 9 SR7 Mar 24, 2025
Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

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

  • Tests are failing
  • In general it seems like there are some Android MauiScrollView layout bugs that were fixed by this PR in NET10 #30672 if for some reason it's tricky to get this PR and tests working on net9 we can just target this to net10 for now

@github-project-automation github-project-automation bot moved this from Ready To Review to Changes Requested in MAUI SDK Ongoing Jul 18, 2025
@PureWeen PureWeen added the p/0 Work that we can't release without label Jul 18, 2025
@kubaflo kubaflo force-pushed the StackLayout-inside-Scrollview-with-horizontal-orientation-not-expanding branch from 431b9d3 to afc1f37 Compare July 18, 2025 23:27
@PureWeen
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen moved this from Changes Requested to Ready To Review in MAUI SDK Ongoing Jul 25, 2025
PureWeen
PureWeen previously approved these changes Jul 25, 2025
@Copilot Copilot AI review requested due to automatic review settings August 1, 2025 00:10
@kubaflo kubaflo force-pushed the StackLayout-inside-Scrollview-with-horizontal-orientation-not-expanding branch from afc1f37 to c87f512 Compare August 1, 2025 00:10
Copy link
Contributor

@Copilot 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.

Pull Request Overview

This PR fixes layout issues in Android where child layouts inside horizontal ScrollViews were not expanding properly to fill the available space. The fix involves setting FillViewport = true on the MauiHorizontalScrollView to ensure proper layout behavior.

  • Sets FillViewport = true on MauiHorizontalScrollView initialization
  • Adds UI test infrastructure to validate the layout behavior
  • Includes test case demonstrating both horizontal and vertical ScrollView scenarios

Reviewed Changes

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

File Description
src/Core/src/Platform/Android/MauiScrollView.cs Sets FillViewport property to true when creating MauiHorizontalScrollView
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25462.cs Adds NUnit test to verify layout expansion in horizontal ScrollView
src/Controls/tests/TestCases.HostApp/Issues/Issue25462.cs Creates test page with horizontal and vertical ScrollViews to demonstrate the fix

Children = {
new Label
{
AutomationId="label",
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

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

The AutomationId 'label' is too generic and may not be unique across the test suite. Consider using a more specific identifier like 'Issue25462Label' or 'HorizontalScrollViewLabel' to ensure uniqueness and prevent WaitForElement failures.

Copilot uses AI. Check for mistakes.

@PureWeen
Copy link
Member

PureWeen commented Aug 1, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen merged commit 3ca9527 into dotnet:main Aug 3, 2025
129 checks passed
@github-project-automation github-project-automation bot moved this from Ready To Review to Done in MAUI SDK Ongoing Aug 3, 2025
SuthiYuvaraj pushed a commit to SuthiYuvaraj/maui that referenced this pull request Aug 12, 2025
…t#26904)

* [Android] Set FillViewport to true to MauiHorizontalScrollView

* Added snapshots

* Update Issue25462.cs

* Updated snapshots

* Fixed mac snapshot
rmarinho pushed a commit that referenced this pull request Aug 13, 2025
* [Android] Set FillViewport to true to MauiHorizontalScrollView

* Added snapshots

* Update Issue25462.cs

* Updated snapshots

* Fixed mac snapshot
@github-actions github-actions bot locked and limited conversation to collaborators Sep 3, 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 p/0 Work that we can't release without platform/android

Projects

Status: Done

7 participants