Skip to content

[Android] ScrollView - Setting SetClipChildren to false#26475

Merged
kubaflo merged 4 commits intodotnet:inflight/currentfrom
kubaflo:fix-20922
Mar 20, 2026
Merged

[Android] ScrollView - Setting SetClipChildren to false#26475
kubaflo merged 4 commits intodotnet:inflight/currentfrom
kubaflo:fix-20922

Conversation

@kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Dec 9, 2024

Issues Fixed

Fixes #20922

<ScrollView>
    <Border HeightRequest="200"
            WidthRequest="200"
            AutomationId="Border"
            BackgroundColor="Red">
        <Border.Shadow>
            <Shadow Radius="20"
                    Brush="Gray"
                    Offset="1,50"/>
        </Border.Shadow>
    </Border>
</ScrollView>
Before After

@kubaflo kubaflo requested a review from a team as a code owner December 9, 2024 12:54
@kubaflo kubaflo requested review from Eilon and jsuarezruiz December 9, 2024 12:54
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Dec 9, 2024
@rmarinho
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@kubaflo kubaflo requested a review from jfversluis as a code owner December 16, 2024 01:37
@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@kubaflo kubaflo self-assigned this Mar 30, 2025
Copilot AI review requested due to automatic review settings August 11, 2025 22:52
Copy link
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.

Pull Request Overview

This PR fixes an issue where shadows on UI elements inside ScrollViews were being clipped on Android. The fix involves setting SetClipChildren(false) on the padding shim container to allow shadow effects to render outside the bounds of their parent container.

  • Adds SetClipChildren(false) to the padding shim in ScrollView handler for Android
  • Includes comprehensive UI test implementation to verify shadow rendering works correctly
  • Addresses the specific case where Grid shadows were not visible within ScrollViews

Reviewed Changes

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

File Description
src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs Adds SetClipChildren(false) to prevent shadow clipping in ScrollView
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20922.cs NUnit test to verify shadow visibility in ScrollView
src/Controls/tests/TestCases.HostApp/Issues/Issue20922.cs Host app test page with Grid shadow inside ScrollView

[Category(UITestCategories.ScrollView)]
public void ShadowShouldWork()
{
App.WaitForElement("Grid");
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

The test is waiting for an element with AutomationId "Grid" but the actual AutomationId in the HostApp is "Grid". While this matches, the test description mentions "Border" in the PR description example, but the actual implementation uses Grid. Ensure the AutomationIds are consistent between the test case and the HostApp implementation.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 16, 2026

🚀 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 -- 26475

Or

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

@StephaneDelcroix
Copy link
Contributor

/azp run maui-pr-uitest, maui-pr-devicetests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephaneDelcroix StephaneDelcroix enabled auto-merge (squash) March 18, 2026 11:07
Copy link
Contributor

@StephaneDelcroix StephaneDelcroix left a comment

Choose a reason for hiding this comment

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

Multi-Model Consensus Review -- Follow-up Note

Status: ✅ Approved & auto-merge enabled

This PR was approved and has auto-merge (squash) enabled. For completeness, here are the minor findings from our multi-model review:

🟡 MODERATE ScrollViewHandler.Android.cs:244 -- paddingShim.SetClipChildren(false) is applied unconditionally to all ScrollViews, not just those with shadows. This disables Android's display-list clipping optimization globally, increasing overdraw. Consider scoping to only apply when content has elevation/shadow in a future follow-up.

🟢 MINOR -- SetClipToPadding(false) may also be needed for complete shadow rendering near padded edges. And the outer MauiScrollView viewport may still clip overflow since only the inner paddingShim is addressed.

These are non-blocking observations for future consideration. The fix is a net improvement for the targeted shadow-clipping bug.

Copy link
Contributor

@StephaneDelcroix StephaneDelcroix left a comment

Choose a reason for hiding this comment

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

Multi-Model Consensus Review -- Follow-up Note

Status: ✅ Approved & auto-merge enabled

This PR was approved and has auto-merge (squash) enabled. For completeness, here are the minor findings from our multi-model review:

🟡 MODERATE ScrollViewHandler.Android.cs:244 -- paddingShim.SetClipChildren(false) is applied unconditionally to all ScrollViews, not just those with shadows. This disables Android's display-list clipping optimization globally, increasing overdraw. Consider scoping to only apply when content has elevation/shadow in a future follow-up.

🟢 MINOR -- SetClipToPadding(false) may also be needed for complete shadow rendering near padded edges. And the outer MauiScrollView viewport may still clip overflow since only the inner paddingShim is addressed.

These are non-blocking observations for future consideration. The fix is a net improvement for the targeted shadow-clipping bug.

@kubaflo kubaflo changed the base branch from main to inflight/current March 18, 2026 14:03
Copy link
Member

@jfversluis jfversluis left a comment

Choose a reason for hiding this comment

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

Build errors and all kinds of unrelated files in this PR @kubaflo

@jfversluis jfversluis added the s/pr-needs-author-input PR needs an update from the author label Mar 19, 2026
@dotnet-policy-service
Copy link
Contributor

Hi @@kubaflo. We have added the "s/pr-needs-author-input" label to this issue, which indicates that we have an open question/action for you before we can take further action. This PRwill be closed automatically in 14 days if we do not hear back from you by then - please feel free to re-open it if you come back to this PR after that time.

@kubaflo
Copy link
Contributor Author

kubaflo commented Mar 19, 2026

/azp run maui-pr-uitests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

## Description

Remove the "Are you waiting for the changes in this PR to be merged?"
note from all Copilot instruction files.

This note was previously required at the top of every PR description so
users could find instructions on how to test PR artifacts. We now have a
**dogfooding comment bot** that automatically posts testing instructions
under each PR, making this manual note redundant.

Copilot agents were still prepending this note to every PR description
because it was hardcoded in:
- `.github/copilot-instructions.md` (main instructions)
- `.github/skills/pr-finalize/SKILL.md` (PR finalization skill)
- `.github/skills/pr-finalize/references/complete-example.md` (example
PR)

### Issues Fixed

N/A — instruction cleanup only.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kubaflo
Copy link
Contributor Author

kubaflo commented Mar 20, 2026

/azp run maui-pr-uitests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@kubaflo kubaflo changed the base branch from inflight/current to main March 20, 2026 14:49
@kubaflo kubaflo dismissed StephaneDelcroix’s stale review March 20, 2026 14:49

The base branch was changed.

@kubaflo
Copy link
Contributor Author

kubaflo commented Mar 20, 2026

/azp run maui-pr-uitests

@azure-pipelines
Copy link

Command 'run-maui-pr-uitests' is not supported by Azure Pipelines.

Supported commands
  • help:
    • Get descriptions, examples and documentation about supported commands
    • Example: help "command_name"
  • list:
    • List all pipelines for this repository using a comment.
    • Example: "list"
  • run:
    • Run all pipelines or specific pipelines for this repository using a comment. Use this command by itself to trigger all related pipelines, or specify specific pipelines to run.
    • Example: "run" or "run pipeline_name, pipeline_name, pipeline_name"
  • where:
    • Report back the Azure DevOps orgs that are related to this repository and org
    • Example: "where"

See additional documentation.

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

kubaflo and others added 2 commits March 21, 2026 00:30
Address review feedback:
- Only disable clipping when content has a shadow (avoids globally
  disabling Android's display-list clipping optimization)
- Add SetClipToPadding(false) for complete shadow rendering near
  padded edges
- Also disable clipping on the outer MauiScrollView viewport to
  prevent shadow overflow clipping

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kubaflo kubaflo added the s/agent-fix-implemented PR author implemented the agent suggested fix label Mar 20, 2026
@kubaflo kubaflo changed the base branch from main to inflight/current March 20, 2026 23:46
@kubaflo kubaflo merged commit b88c706 into dotnet:inflight/current Mar 20, 2026
3 of 12 checks passed
PureWeen pushed a commit that referenced this pull request Mar 24, 2026
### Issues Fixed

Fixes #20922

```
<ScrollView>
    <Border HeightRequest="200"
            WidthRequest="200"
            AutomationId="Border"
            BackgroundColor="Red">
        <Border.Shadow>
            <Shadow Radius="20"
                    Brush="Gray"
                    Offset="1,50"/>
        </Border.Shadow>
    </Border>
</ScrollView>
```

|Before|After|
|--|--|
|<img
src="https://github.com/user-attachments/assets/2d0e8e59-5b3e-4953-bc96-75658cd7555e"
width="300px"/>|<img
src="https://github.com/user-attachments/assets/3f31a65f-5cdc-4811-bbbe-f008af39f285"
width="300px"/>|

---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-scrollview ScrollView community ✨ Community Contribution platform/android s/agent-fix-implemented PR author implemented the agent suggested fix s/pr-needs-author-input PR needs an update from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shadow Doesn't Work on Grid on Android

6 participants