Skip to content

[Android] Prevent vertical scroll in horizontal ScrollView - #37880

Merged
kubaflo merged 5 commits into
dotnet:inflight/currentfrom
Shalini-Ashokan:fix-37335
Aug 27, 2026
Merged

kubaflo merged 5 commits into
dotnet:inflight/currentfrom
Shalini-Ashokan:fix-37335

Conversation

@Shalini-Ashokan

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details

When ScrollView.Orientation="Horizontal" on Android, the content unexpectedly scrolls a few pixels vertically too, even though only horizontal scrolling was requested.

Root Cause

Android's outer scroll container calculates vertical scroll range using its inner horizontal-scroll child's height vs. its own padded content area. MAUI's code sized that inner child using the full (unpadded) outer height, leaving a small leftover gap equal to the padding — causing phantom vertical scroll.

Description of Change

In MauiScrollView.cs , OnMeasure / OnLayout now subtract PaddingTop/Bottom/Left/Right when sizing the inner horizontal scroll view, and offset its layout position by PaddingLeft/Top . This makes the inner view exactly match the true content area, eliminating the leftover scroll range.

Validated the behavior in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed

Fixes #37335

Output ScreenShot

Before After
37335-Android-BeforeFix.mov
37335-AfterFix.mov

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37880

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37880"

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Aug 27, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Aug 27, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@Shalini-Ashokan Shalini-Ashokan changed the title [WIP] [Android] Prevent vertical scroll in horizontal ScrollView [Android] Prevent vertical scroll in horizontal ScrollView Aug 27, 2026
@sheiksyedm
sheiksyedm marked this pull request as ready for review August 27, 2026 11:08
Copilot AI lite review requested due to automatic review settings August 27, 2026 11:08
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 an Android-specific ScrollView behavior where Orientation="Horizontal" could still allow a small amount of vertical scrolling when padding is applied (e.g., from SafeArea insets). The fix adjusts measurement and layout of the inner horizontal scroll container to size to the padded content area and position it at the padding offset, eliminating the phantom vertical scroll range.

Changes:

  • Adjust MauiScrollView horizontal-child measurement to subtract Padding* so the child matches the true content area.
  • Adjust MauiScrollView horizontal-child layout to offset by PaddingLeft/Top and size to the padded width/height.
  • Add an Android device test asserting the inner MauiHorizontalScrollView is measured/laied out to the padded content area and that the parent can’t scroll vertically.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Core/src/Platform/Android/MauiScrollView.cs Sizes and positions the inner horizontal scroll view using the padded content bounds to prevent unintended vertical scroll range.
src/Core/tests/DeviceTests/Handlers/ScrollView/ScrollViewHandlerTests.Android.cs Adds coverage to validate the padded horizontal-orientation layout/measurement and confirm no vertical scrolling is possible.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Aug 27, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Expert Review — 3 findings

See inline comments for details.

var hScrollViewWidth = this.MeasuredWidth;
// Subtract padding (e.g. from SafeArea insets) so the child fits the content area exactly;
// otherwise NestedScrollView sees the overflow as vertical scroll range.
var hScrollViewHeight = Math.Max(0, this.MeasuredHeight - PaddingTop - PaddingBottom);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔍 AI-Generated Review (multi-model)

[major] Layout Measure-Arrange Correctness — Clamping the child height to zero does not eliminate the vertical range when the padding is at least the view height. NestedScrollView computes its range as childHeight - (height - PaddingTop - PaddingBottom), so a 40 px horizontal ScrollView with a 60 px top safe-area inset gets a 0 px child but still has a 20 px range and returns true from CanScrollVertically(1). The short-control case therefore still exhibits the reported vertical scrolling.

var hScrollViewHeight = bottom - top;
var hScrollViewWidth = right - left;
var hScrollViewHeight = Math.Max(0, (bottom - top) - PaddingTop - PaddingBottom);
var hScrollViewWidth = Math.Max(0, (right - left) - PaddingLeft - PaddingRight);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔍 AI-Generated Review (multi-model)

[major] Logic and Correctness Verification — Narrowing an already-laid-out RTL viewport after an inset change leaves it short of the logical start. For example, a 2,000 px child initially reaches the RTL edge at ScrollX=1000 in a 1,000 px viewport; adding 100 px of side padding makes the new maximum 1,100, but _checkedForRtlScroll remains true and HorizontalScrollView retains 1,000, hiding the rightmost 100 px. This occurs when SafeAreaEdges or window insets change after layout, while the new test sets padding only before the first layout.

//so its parent the NestedScrollView can scroll vertically
hScrollViewHeight = _isBidirectional ? Math.Max(hScrollViewHeight, scrollViewContentHeight) : hScrollViewHeight;
_hScrollView.Layout(0, 0, hScrollViewWidth, hScrollViewHeight);
_hScrollView.Layout(PaddingLeft, PaddingTop, PaddingLeft + hScrollViewWidth, PaddingTop + hScrollViewHeight);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔍 AI-Generated Review (multi-model)

[major] Performance-Critical Path Optimization — PaddingLeft and PaddingTop are each read twice here after already being read for the size calculations above. These Android View getters cross JNI, adding four redundant managed/native calls on every horizontal or bidirectional OnLayout; cache the padding values once per pass.

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI Review Summary

@Shalini-Ashokan — new AI review results are available based on commit 7f6d2f8.

Gate Passed Confidence Low Platform Android


🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix

Gate Result: ✅ PASSED

Platform: ANDROID · Base: main · Merge base: 073c90c8

Test Without Fix (expect FAIL) With Fix (expect PASS)
📱 ScrollViewHandlerTests (MauiScrollViewHasNoVerticalScrollRangeWithPaddingInHorizontalOrientation) Category=ScrollView ✅ FAIL — 559s ✅ PASS — 386s
🔴 Without fix — 📱 ScrollViewHandlerTests (MauiScrollViewHasNoVerticalScrollRangeWithPaddingInHorizontalOrientation): FAIL ✅ · 559s

(no coded error found; showing last 1200 chars)

"totalMemoryBytes": 8322998272
          },
          "target": {
            "kind": "emulator",
            "name": "sdk_gphone_x86_64",
            "identifier": "emulator-5554",
            "operatingSystem": "Android",
            "operatingSystemVersion": "11",
            "apiLevel": 30,
            "architecture": "x86_64",
            "supportedArchitectures": [
              "x86_64",
              "x86",
              "arm64-v8a",
              "armeabi-v7a",
              "armeabi"
            ],
            "manufacturer": "Google",
            "model": "sdk_gphone_x86_64",
            "productName": "sdk_gphone_x86_64",
            "buildFingerprint": "google/sdk_gphone_x86_64/generic_x86_64_arm64:11/RSR1.201211.001/7027799:user/release-keys",
            "cpuModel": "0",
            "cpuMaxFrequencyHertz": 2000,
            "totalMemoryBytes": 2077544448
          }
        }
      }
      <<XHARNESS_RESULT_END>>
info: Attempting to remove apk 'com.microsoft.maui.core.devicetests'..
info: Successfully uninstalled com.microsoft.maui.core.devicetests
XHarness exit code: 1 (TESTS_FAILED)
  Passed: 0
  Failed: 1
  Skipped: 0
  Total: 1
  Tests completed with exit code: 1
🟢 With fix — 📱 ScrollViewHandlerTests (MauiScrollViewHasNoVerticalScrollRangeWithPaddingInHorizontalOrientation): PASS ✅ · 386s

(no coded error found; showing last 1200 chars)

914000,
            "totalMemoryBytes": 8322998272
          },
          "target": {
            "kind": "emulator",
            "name": "sdk_gphone_x86_64",
            "identifier": "emulator-5554",
            "operatingSystem": "Android",
            "operatingSystemVersion": "11",
            "apiLevel": 30,
            "architecture": "x86_64",
            "supportedArchitectures": [
              "x86_64",
              "x86",
              "arm64-v8a",
              "armeabi-v7a",
              "armeabi"
            ],
            "manufacturer": "Google",
            "model": "sdk_gphone_x86_64",
            "productName": "sdk_gphone_x86_64",
            "buildFingerprint": "google/sdk_gphone_x86_64/generic_x86_64_arm64:11/RSR1.201211.001/7027799:user/release-keys",
            "cpuModel": "0",
            "cpuMaxFrequencyHertz": 2000,
            "totalMemoryBytes": 2077544448
          }
        }
      }
      <<XHARNESS_RESULT_END>>
info: Attempting to remove apk 'com.microsoft.maui.core.devicetests'..
info: Successfully uninstalled com.microsoft.maui.core.devicetests
XHarness exit code: 0
  Passed: 1
  Failed: 0
  Skipped: 0
  Total: 1
  Tests completed successfully
📁 Fix files reverted (1 files)
  • src/Core/src/Platform/Android/MauiScrollView.cs

📋 Pre-Flight — Context & Validation

Issue: #37335 - Orientation property as Horizontal is not working properly in ScrollView on Android platform
PR: #37880 - [Android] Prevent vertical scroll in horizontal ScrollView
Platform: Android
Review commit: d600db479dda733c608cb64e62c57316d8ac1c89
Merge base: 073c90c8911e2e7adc0082a13ef5a3a22d4b4d29
Files changed: 1 implementation, 1 Android Core device-test file

Problem and evidence

  • A horizontal-only ScrollView can move vertically by a few pixels on Android when the outer MauiScrollView has padding (including safe-area padding).
  • The outer NestedScrollView owns a MauiHorizontalScrollView. Before the PR, OnMeasure and OnLayout sized that child to the outer view's full bounds, so the child exceeded the outer view's padded content viewport.
  • The gate already proved the added test fails without the production fix and passes with it. Do not rerun the A/B gate.

Existing PR approach

The PR changes src/Core/src/Platform/Android/MauiScrollView.cs to subtract all four padding values from the horizontal child's measured and laid-out dimensions, clamp those dimensions to zero, and lay the child out from (PaddingLeft, PaddingTop). Its test is
MauiScrollViewHasNoVerticalScrollRangeWithPaddingInHorizontalOrientation in
src/Core/tests/DeviceTests/Handlers/ScrollView/ScrollViewHandlerTests.Android.cs.

Alternative-candidate constraints

  • Each candidate must use a mechanism meaningfully different from the PR's direct child-size subtraction and padding-offset layout.
  • The baseline allow-list is expected to contain only src/Core/src/Platform/Android/MauiScrollView.cs; inspect .github/.baseline-state.json after establishing the baseline and do not edit outside RevertedFiles.
  • Preserve bidirectional scrolling, no-padding horizontal sizing, RTL behavior, and safe-area/inset handling.
  • Follow .github/instructions/android.instructions.md, threading-async.instructions.md, performance-hotpaths.instructions.md, and helix-device-tests.instructions.md.
  • Perform the try-fix skill's inline expert self-review only; the dedicated expert pass is deferred to STEP 5b.

Bounded test command

Run only the detected primary test and the directly coupled no-padding regression in one Android Core device-test invocation:

pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Core -Platform android -TestFilter "Category=ScrollView" -IncludeClasses "Microsoft.Maui.DeviceTests.ScrollViewHandlerTests" -IncludeMethods "MauiScrollViewHasNoVerticalScrollRangeWithPaddingInHorizontalOrientation,MauiScrollViewGetsFullHeightInHorizontalOrientation"

No additional mandatory regression tests were supplied. One implementation/test pass and at most one focused correction/retest are allowed per candidate.

Existing review context

  • No inline PR review comments were present when pre-flight ran.
  • The mechanical regression cross-reference reported no recent labeled bug-fix overlap in the changed files.
  • ViewBaseTests was detected as the impacted UI-test category, but UI tests are outside this bounded STEP 5a test scope.
  • The worktree contains pre-existing unrelated changes under .github/ and eng/; leave them untouched.

🔬 Code Review — Deep Analysis

Code Review — PR #37880

Independent Assessment

What this changes: On Android, the outer MauiScrollView now measures and lays out its inner MauiHorizontalScrollView within the outer view's padded content bounds. The added device test verifies that geometry and the ordinary-padding case where the outer view has no downward vertical scroll range.

Inferred motivation: Padding applied to the outer NestedScrollView, including safe-area padding, previously left the horizontal child larger than the usable viewport and created an unintended vertical scroll range.

Prior Review Reconciliation

No prior error-level inline findings were present on the current PR revision. The existing Copilot review reported no comments.

Blast Radius Assessment

  • Runs for all horizontal and bidirectional MauiScrollView instances during layout; the measurement override is limited to horizontal-only instances.
  • No startup or static-state impact.
  • Platform-specific, performance-sensitive Android measure/layout code; the platform cap is medium, reduced to low because required-check status was unavailable.

Findings

  1. ❌ Error — Excessive vertical padding can still produce a vertical range. At MauiScrollView.cs:387, clamping the inner height to zero cannot make NestedScrollView's usable height non-negative when PaddingTop + PaddingBottom exceeds the view height. The current test covers only padding smaller than the viewport.
  2. ❌ Error — Runtime inset changes can leave RTL horizontal scrolling short of the logical start. At MauiScrollView.cs:403, reducing the viewport after the first RTL positioning increases the maximum horizontal offset, but the padding/inset update does not reset _checkedForRtlScroll.
  3. ⚠️ Warning — Repeated JNI-backed padding reads in OnLayout. At MauiScrollView.cs:408, the padding properties are read again after the size calculation. Cache the four values once per layout pass.

Failure-Mode Probing

  • Padding larger than the viewport: the child clamps to zero, but the outer padded viewport is negative; the new ordinary-padding assertion does not exercise this boundary.
  • Insets change after initial RTL layout: _checkedForRtlScroll remains true, so the existing post-layout correction does not move to the newly increased maximum offset.
  • Bidirectional orientation: the modified layout path also runs for Both; any refinement must preserve vertical range and diagonal scrolling there.
  • Reconnect/default behavior: no new subscriptions, shared state, or disconnected-handler access is introduced.

External Output Contract

Not applicable.

Verdict: NEEDS_CHANGES

Confidence: low
Summary: The ordinary horizontal-padding fix is directionally sound and its gate test is effective, but the expert review identified unhandled boundary and dynamic-RTL cases in the modified layout behavior. A focused refinement should preserve the submitted fix while addressing the actionable lifecycle/performance concerns and explicitly record any boundary uncertainty.


🛠️ Try-Fix — Analysis & Comparison

Try-Fix Alternatives for PR #37880

Candidate 1 — ViewGroup contract restoration

Model: claude-opus-5
Result: BLOCKED
Artifact directory: CustomAgentLogsTmp/PRState/37880/PRAgent/try-fix/attempt-1

The candidate proposed overriding MeasureChildWithMargins for the inner
horizontal scroll view, using Android's child-measure-spec contract to account
for parent padding, and returning placement to FrameLayout.layoutChildren.
Unlike the PR, it would not subtract individual padding edges or manually
offset the child.

No diff was produced and neither bounded device test ran. The mandatory
baseline script rejected the pre-existing unrelated tracked changes under
.github/ and eng/, did not create baseline state, and therefore prohibited
any source edit. The exact restore command completed via the accepted no-state
path; source files remain unchanged. Inline self-review: 0 findings.

Candidate 2 — Outer FillViewport policy

Model: gpt-5.6-sol
Result: BLOCKED
Artifact directory: CustomAgentLogsTmp/PRState/37880/PRAgent/try-fix/attempt-2

The candidate proposed enabling the outer NestedScrollView.FillViewport
policy in horizontal-only mode so Android's native second measurement pass
derives the padded viewport. It treats the missing outer fill-viewport policy
as the root cause, avoiding both the PR's explicit edge arithmetic/manual
placement and Candidate 1's MeasureChildWithMargins contract override.

No diff was produced and neither bounded device test ran. The same mandatory
baseline safety gate rejected the pre-existing unrelated tracked changes and
created no baseline state, so edits were forbidden. The exact restore command
completed via the accepted no-state path; source files remain unchanged.
Inline self-review: 0 findings.

Aggregate status

Two candidates were attempted, which is the configured maximum. Both produced
distinct mechanism-level designs but were blocked before implementation by the
baseline script's clean-worktree precondition. No gate artifact was changed,
no candidate diff remains applied, and no test result is claimed.


🏁 Report — Final Recommendation

⚠️ Final Recommendation: REQUEST CHANGES

Winner: pr-plus-reviewer

The submitted PR proves and fixes the ordinary padded-horizontal case, but the expert review found three issues in the modified Android layout path. The consolidated pr-plus-reviewer candidate preserves the PR fix, prevents the horizontal-only outer view from intercepting or reporting vertical scrolling when padding exceeds its height, re-arms RTL start positioning when the horizontal viewport width changes, and caches padding values in the measure/layout hot path.

Comparative ranking

Rank Candidate Implementation Regression evidence Assessment
1 pr-plus-reviewer PR fix plus the consolidated expert refinements PASS: 2/2 bounded Android tests, including the padded regression and existing no-padding sizing test Best behavioral coverage. The build emitted RS0016 for the new public CanScrollVertically(int) override, so the candidate still needs either the proper PublicAPI.Unshipped.txt entry or an internal implementation that avoids adding an override to the declared public surface. Per the execution contract, this was recorded rather than repaired/retested.
2 pr Explicitly sizes and positions the horizontal child inside the padded viewport PASS: trusted Gate test fails without the fix and passes with it Correct for the reported ordinary-padding case, but leaves the expert-reviewed excessive-padding and dynamic RTL viewport-change cases unresolved and repeats JNI-backed padding reads in OnLayout.
3 try-fix-1 Proposed MeasureChildWithMargins/GetChildMeasureSpec contract restoration BLOCKED: no diff; tests not run Plausible design only. It cannot outrank implemented candidates with passing regression evidence.
4 try-fix-2 Proposed outer FillViewport policy BLOCKED: no diff; tests not run Unimplemented and unvalidated; its own analysis notes that fill-viewport growth does not cap tall content and may not satisfy the pinned geometry.

Expert findings against the submitted PR

  1. Excessive vertical padding can leave NestedScrollView with a positive vertical range even after the child height clamps to zero.
  2. A narrower viewport after a runtime inset/padding change can leave an RTL horizontal view short of its new logical start because _checkedForRtlScroll remains set.
  3. The new OnLayout arithmetic repeatedly crosses JNI for padding values.

Validation and uncertainty

The candidate was built and tested from /home/vsts/work/_temp/pr-37880-pr-plus-reviewer; all build products and XHarness output were rooted in that sandbox. The required Android command reported 2 passed, 0 failed, 0 skipped. The trusted Gate permits approval on test causality, but the raw PR does not win and the expert findings are blocking, so the submitted PR requires changes. Required-check status outside the supplied Gate remains undetermined because GitHub CLI authentication was unavailable.

Required follow-up

Adopt the pr-plus-reviewer behavior, resolve the RS0016 public-API declaration warning without broad suppression, and retain the focused Android regression coverage.


📱 UI Tests — ViewBaseTests

Detected UI test categories: ViewBaseTests

✅ Deep UI tests — 118 passed, 0 failed, 1 skipped across 1 category on platform-pool agent (replaces in-process counts above).

🧪 UI Test Execution Results (deep, platform pool)

Category Tests Snapshot diffs
ViewBaseTests 118/119 (1 skipped) ✓ —
📎 Download drop-deep-uitests artifact (TRX + snapshot diffs)

🧭 Next Steps — reviewer changes required

The reviewer-enhanced candidate identified changes that are not yet in the submitted PR.

Why: The pr-plus-reviewer candidate preserves the proven PR fix while addressing the expert-reviewed excessive-padding, RTL viewport-change, and layout hot-path concerns, and both required Android tests passed. It wins with a recorded RS0016 public-API warning that must be resolved before merge.

Address the actionable findings in this review before merging.

@MauiBot MauiBot added the s/agent-changes-requested AI agent recommends changes - found a better alternative or issues label Aug 27, 2026
@MauiBot MauiBot added s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-fix-win AI found a better alternative fix than the PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 27, 2026
@kubaflo
kubaflo changed the base branch from main to inflight/current August 27, 2026 22:02
@kubaflo
kubaflo merged commit e869e73 into dotnet:inflight/current Aug 27, 2026
41 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR11 milestone Aug 27, 2026
kubaflo pushed a commit that referenced this pull request Sep 2, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->


### Issue Details
When ScrollView.Orientation="Horizontal" on Android, the content
unexpectedly scrolls a few pixels vertically too, even though only
horizontal scrolling was requested.

### Root Cause
Android's outer scroll container calculates vertical scroll range using
its inner horizontal-scroll child's height vs. its own padded content
area. MAUI's code sized that inner child using the full (unpadded) outer
height, leaving a small leftover gap equal to the padding — causing
phantom vertical scroll.

### Description of Change
In MauiScrollView.cs , OnMeasure / OnLayout now subtract
PaddingTop/Bottom/Left/Right when sizing the inner horizontal scroll
view, and offset its layout position by PaddingLeft/Top . This makes the
inner view exactly match the true content area, eliminating the leftover
scroll range.

Validated the behavior in the following platforms
 
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
 
### Issues Fixed
  
Fixes #37335 

### Output  ScreenShot

|Before|After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/677494c4-4e09-4e1b-af46-eeb48a3c2f7a"
>| <video
src="https://github.com/user-attachments/assets/0180fcf3-6c7e-482b-bad0-7893e0838aa9">|
kubaflo pushed a commit that referenced this pull request Sep 3, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->


### Issue Details
When ScrollView.Orientation="Horizontal" on Android, the content
unexpectedly scrolls a few pixels vertically too, even though only
horizontal scrolling was requested.

### Root Cause
Android's outer scroll container calculates vertical scroll range using
its inner horizontal-scroll child's height vs. its own padded content
area. MAUI's code sized that inner child using the full (unpadded) outer
height, leaving a small leftover gap equal to the padding — causing
phantom vertical scroll.

### Description of Change
In MauiScrollView.cs , OnMeasure / OnLayout now subtract
PaddingTop/Bottom/Left/Right when sizing the inner horizontal scroll
view, and offset its layout position by PaddingLeft/Top . This makes the
inner view exactly match the true content area, eliminating the leftover
scroll range.

Validated the behavior in the following platforms
 
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
 
### Issues Fixed
  
Fixes #37335 

### Output  ScreenShot

|Before|After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/677494c4-4e09-4e1b-af46-eeb48a3c2f7a"
>| <video
src="https://github.com/user-attachments/assets/0180fcf3-6c7e-482b-bad0-7893e0838aa9">|
kubaflo pushed a commit that referenced this pull request Sep 6, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->


### Issue Details
When ScrollView.Orientation="Horizontal" on Android, the content
unexpectedly scrolls a few pixels vertically too, even though only
horizontal scrolling was requested.

### Root Cause
Android's outer scroll container calculates vertical scroll range using
its inner horizontal-scroll child's height vs. its own padded content
area. MAUI's code sized that inner child using the full (unpadded) outer
height, leaving a small leftover gap equal to the padding — causing
phantom vertical scroll.

### Description of Change
In MauiScrollView.cs , OnMeasure / OnLayout now subtract
PaddingTop/Bottom/Left/Right when sizing the inner horizontal scroll
view, and offset its layout position by PaddingLeft/Top . This makes the
inner view exactly match the true content area, eliminating the leftover
scroll range.

Validated the behavior in the following platforms
 
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
 
### Issues Fixed
  
Fixes #37335 

### Output  ScreenShot

|Before|After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/677494c4-4e09-4e1b-af46-eeb48a3c2f7a"
>| <video
src="https://github.com/user-attachments/assets/0180fcf3-6c7e-482b-bad0-7893e0838aa9">|
kubaflo pushed a commit that referenced this pull request Sep 7, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->


### Issue Details
When ScrollView.Orientation="Horizontal" on Android, the content
unexpectedly scrolls a few pixels vertically too, even though only
horizontal scrolling was requested.

### Root Cause
Android's outer scroll container calculates vertical scroll range using
its inner horizontal-scroll child's height vs. its own padded content
area. MAUI's code sized that inner child using the full (unpadded) outer
height, leaving a small leftover gap equal to the padding — causing
phantom vertical scroll.

### Description of Change
In MauiScrollView.cs , OnMeasure / OnLayout now subtract
PaddingTop/Bottom/Left/Right when sizing the inner horizontal scroll
view, and offset its layout position by PaddingLeft/Top . This makes the
inner view exactly match the true content area, eliminating the leftover
scroll range.

Validated the behavior in the following platforms
 
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
 
### Issues Fixed
  
Fixes #37335 

### Output  ScreenShot

|Before|After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/677494c4-4e09-4e1b-af46-eeb48a3c2f7a"
>| <video
src="https://github.com/user-attachments/assets/0180fcf3-6c7e-482b-bad0-7893e0838aa9">|
kubaflo pushed a commit that referenced this pull request Sep 8, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->


### Issue Details
When ScrollView.Orientation="Horizontal" on Android, the content
unexpectedly scrolls a few pixels vertically too, even though only
horizontal scrolling was requested.

### Root Cause
Android's outer scroll container calculates vertical scroll range using
its inner horizontal-scroll child's height vs. its own padded content
area. MAUI's code sized that inner child using the full (unpadded) outer
height, leaving a small leftover gap equal to the padding — causing
phantom vertical scroll.

### Description of Change
In MauiScrollView.cs , OnMeasure / OnLayout now subtract
PaddingTop/Bottom/Left/Right when sizing the inner horizontal scroll
view, and offset its layout position by PaddingLeft/Top . This makes the
inner view exactly match the true content area, eliminating the leftover
scroll range.

Validated the behavior in the following platforms
 
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
 
### Issues Fixed
  
Fixes #37335 

### Output  ScreenShot

|Before|After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/677494c4-4e09-4e1b-af46-eeb48a3c2f7a"
>| <video
src="https://github.com/user-attachments/assets/0180fcf3-6c7e-482b-bad0-7893e0838aa9">|
kubaflo pushed a commit that referenced this pull request Sep 9, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->


### Issue Details
When ScrollView.Orientation="Horizontal" on Android, the content
unexpectedly scrolls a few pixels vertically too, even though only
horizontal scrolling was requested.

### Root Cause
Android's outer scroll container calculates vertical scroll range using
its inner horizontal-scroll child's height vs. its own padded content
area. MAUI's code sized that inner child using the full (unpadded) outer
height, leaving a small leftover gap equal to the padding — causing
phantom vertical scroll.

### Description of Change
In MauiScrollView.cs , OnMeasure / OnLayout now subtract
PaddingTop/Bottom/Left/Right when sizing the inner horizontal scroll
view, and offset its layout position by PaddingLeft/Top . This makes the
inner view exactly match the true content area, eliminating the leftover
scroll range.

Validated the behavior in the following platforms
 
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
 
### Issues Fixed
  
Fixes #37335 

### Output  ScreenShot

|Before|After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/677494c4-4e09-4e1b-af46-eeb48a3c2f7a"
>| <video
src="https://github.com/user-attachments/assets/0180fcf3-6c7e-482b-bad0-7893e0838aa9">|
kubaflo pushed a commit that referenced this pull request Sep 11, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->


### Issue Details
When ScrollView.Orientation="Horizontal" on Android, the content
unexpectedly scrolls a few pixels vertically too, even though only
horizontal scrolling was requested.

### Root Cause
Android's outer scroll container calculates vertical scroll range using
its inner horizontal-scroll child's height vs. its own padded content
area. MAUI's code sized that inner child using the full (unpadded) outer
height, leaving a small leftover gap equal to the padding — causing
phantom vertical scroll.

### Description of Change
In MauiScrollView.cs , OnMeasure / OnLayout now subtract
PaddingTop/Bottom/Left/Right when sizing the inner horizontal scroll
view, and offset its layout position by PaddingLeft/Top . This makes the
inner view exactly match the true content area, eliminating the leftover
scroll range.

Validated the behavior in the following platforms
 
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
 
### Issues Fixed
  
Fixes #37335 

### Output  ScreenShot

|Before|After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/677494c4-4e09-4e1b-af46-eeb48a3c2f7a"
>| <video
src="https://github.com/user-attachments/assets/0180fcf3-6c7e-482b-bad0-7893e0838aa9">|
kubaflo pushed a commit that referenced this pull request Sep 15, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->


### Issue Details
When ScrollView.Orientation="Horizontal" on Android, the content
unexpectedly scrolls a few pixels vertically too, even though only
horizontal scrolling was requested.

### Root Cause
Android's outer scroll container calculates vertical scroll range using
its inner horizontal-scroll child's height vs. its own padded content
area. MAUI's code sized that inner child using the full (unpadded) outer
height, leaving a small leftover gap equal to the padding — causing
phantom vertical scroll.

### Description of Change
In MauiScrollView.cs , OnMeasure / OnLayout now subtract
PaddingTop/Bottom/Left/Right when sizing the inner horizontal scroll
view, and offset its layout position by PaddingLeft/Top . This makes the
inner view exactly match the true content area, eliminating the leftover
scroll range.

Validated the behavior in the following platforms
 
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
 
### Issues Fixed
  
Fixes #37335 

### Output  ScreenShot

|Before|After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/677494c4-4e09-4e1b-af46-eeb48a3c2f7a"
>| <video
src="https://github.com/user-attachments/assets/0180fcf3-6c7e-482b-bad0-7893e0838aa9">|
kubaflo pushed a commit that referenced this pull request Sep 18, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->


### Issue Details
When ScrollView.Orientation="Horizontal" on Android, the content
unexpectedly scrolls a few pixels vertically too, even though only
horizontal scrolling was requested.

### Root Cause
Android's outer scroll container calculates vertical scroll range using
its inner horizontal-scroll child's height vs. its own padded content
area. MAUI's code sized that inner child using the full (unpadded) outer
height, leaving a small leftover gap equal to the padding — causing
phantom vertical scroll.

### Description of Change
In MauiScrollView.cs , OnMeasure / OnLayout now subtract
PaddingTop/Bottom/Left/Right when sizing the inner horizontal scroll
view, and offset its layout position by PaddingLeft/Top . This makes the
inner view exactly match the true content area, eliminating the leftover
scroll range.

Validated the behavior in the following platforms
 
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
 
### Issues Fixed
  
Fixes #37335 

### Output  ScreenShot

|Before|After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/677494c4-4e09-4e1b-af46-eeb48a3c2f7a"
>| <video
src="https://github.com/user-attachments/assets/0180fcf3-6c7e-482b-bad0-7893e0838aa9">|
kubaflo pushed a commit that referenced this pull request Sep 21, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->


### Issue Details
When ScrollView.Orientation="Horizontal" on Android, the content
unexpectedly scrolls a few pixels vertically too, even though only
horizontal scrolling was requested.

### Root Cause
Android's outer scroll container calculates vertical scroll range using
its inner horizontal-scroll child's height vs. its own padded content
area. MAUI's code sized that inner child using the full (unpadded) outer
height, leaving a small leftover gap equal to the padding — causing
phantom vertical scroll.

### Description of Change
In MauiScrollView.cs , OnMeasure / OnLayout now subtract
PaddingTop/Bottom/Left/Right when sizing the inner horizontal scroll
view, and offset its layout position by PaddingLeft/Top . This makes the
inner view exactly match the true content area, eliminating the leftover
scroll range.

Validated the behavior in the following platforms
 
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
 
### Issues Fixed
  
Fixes #37335 

### Output  ScreenShot

|Before|After|
|--|--|
| <video
src="https://github.com/user-attachments/assets/677494c4-4e09-4e1b-af46-eeb48a3c2f7a"
>| <video
src="https://github.com/user-attachments/assets/0180fcf3-6c7e-482b-bad0-7893e0838aa9">|
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 27, 2026
@github-actions github-actions Bot modified the milestones: .NET 10 SR11, .NET 10 SR12 Oct 21, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 7f6d2f8d Deployed Aug 27, 2026 by Shalini-Ashokan via conclusion #1565
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 s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Orientation property as Horizontal is not working properly in ScrollView on Android platform

4 participants