Skip to content

[Android] Don't leave a background tint on the toolbar for a solid BarBackground - #40550

Merged
kubaflo merged 5 commits into
dotnet:candidate/11.0.1xx-sr3from
marcelomoresco:fix/40372-shell-toolbar-gradient-net11
Nov 26, 2026
Merged

kubaflo merged 5 commits into
dotnet:candidate/11.0.1xx-sr3from
marcelomoresco:fix/40372-shell-toolbar-gradient-net11

Conversation

@marcelomoresco

Copy link
Copy Markdown
Contributor

Target Branch

This PR is for Initial base
New features, API changes, or .NET 12 work (including .NET 12 fixes) main
.NET 11 servicing fixes net11, for review
Older servicing, release integration, infrastructure, or documentation The branch designated for that work

For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into net11; agents must not retarget or merge.

Note: the issue was confirmed reproducing on .NET MAUI 10.0.110, and the same
code path is unchanged on net11, so this targets net11 as the current
servicing line; please redirect if a 10.0.1xx backport is the intended route
instead.

Description of Change

On Android, Shell's toolbar UpdateBarBackground applied a solid
BarBackground as a view background tint (BackgroundTintList with
PorterDuff.Mode.Src) instead of coloring the background drawable itself.
That tint stays on the toolbar view, so when a custom
IShellToolbarAppearanceTracker.SetAppearance later calls
toolbar.SetBackgroundResource(...) with a gradient drawable, the tint paints
over it and the gradient renders as the last solid color instead.

The fix tints the current background drawable (Mutate() +
SetTintList/SetTintMode) instead of the view. The tint goes away together
with that drawable when the background is replaced, so a later gradient (or
any other custom background) shows correctly. The drawable's own fill color
is untouched, so ShellToolbarAppearanceTracker.CaptureNativeColors under
Material 3 keeps reading the native color correctly. The existing gradient
BarBackground code path (the else branch) is unchanged.

Added a device test, SolidBarBackgroundDoesNotLeaveViewBackgroundTint, in
NavigationPageTests.Android.cs.

Local verification (Android)

Checked by hand on an Android emulator (API 36) with a small .NET 10 test app
containing an exact copy of the corrected method
(the MAUI repo's own main/net11 build requires .NET 11, not available on
this machine):

  1. Custom renderer from the issue: without the fix, the toolbar is solid
    white; with the fix, the red→blue gradient renders. Screenshot below
    (left: without the fix, right: with the fix).
  2. Regression check — a plain solid Shell BarBackground color change at
    runtime (orange → green): identical pixels with and without the fix
    (#FFA500 → #008000), so solid backgrounds keep working.
  3. NavigationPage.BarBackground orange → LinearGradientBrush → green:
    without the fix the gradient never shows (stays #FFA500); with the fix
    the gradient shows (#F1000E…#0E00F1) before returning to green. This is
    an additional improvement beyond the reported Shell case, worth noting.

Before/after comparison

Not verified

  • The MAUI repository itself was not built (its main/net11 branches
    require .NET 11, this machine has .NET 10), and the new device test
    (SolidBarBackgroundDoesNotLeaveViewBackgroundTint) was not executed.
  • Material 3 with UseMauiAndroidSystemBarBackgrounds enabled was not
    checked — that path doesn't go through this code.
  • Shell.Background with a brush (MAUI 11-only) was not checked.

Issues Fixed

Fixes #40372

…rBackground

UpdateBarBackground applied a solid BarBackground as a view background tint
(PorterDuff.Mode.Src). The tint stays on the toolbar, so a background drawable
set later, such as the gradient a custom IShellToolbarAppearanceTracker sets
with SetBackgroundResource, was painted over with the solid color.

Tint the current background drawable instead. The tint goes away with that
drawable, so a replaced background shows as set. The drawable's fill color is
not changed, so ShellToolbarAppearanceTracker.CaptureNativeColors still reads
the native color under Material 3.

Fixes dotnet#40372
@github-actions

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Nov 24, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot 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.

Expert Review — 0 findings

Reviewed commit b04cf29.

Keep only comments that follow the conventions of the surrounding code.

Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot 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.

Expert Review — 0 findings

Reviewed commit eade114.

@kubaflo
kubaflo deleted the branch dotnet:net11 November 24, 2026 14:43
@kubaflo kubaflo closed this Nov 24, 2026
@kubaflo kubaflo reopened this Nov 24, 2026
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:48 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:48 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:49 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:51 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:52 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:53 — with GitHub Actions Inactive
@kubaflo

kubaflo commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

/review run-tests

@github-actions

This comment has been minimized.

@kubaflo

kubaflo commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

/review run-tests

@github-actions

This comment has been minimized.

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

Some tests failed - could you please check?

kubaflo added a commit that referenced this pull request Nov 25, 2026
…PR (#40612)

### Description of Change

`/review run-tests` builds run on a `run-tests/*` dispatch commit, so
Azure Pipelines reports their jobs on that commit and the PR's checks
panel only shows the `maui-pr-uitests (selected run)` /
`maui-pr-devicetests (selected run)` summary checks.

`Update-RunTestsResults.ps1` now mirrors every job of the selected build
as its own check on the PR head, e.g.

- `maui-pr-uitests (Android UITests CoreClr Controls (API 30) Shell1)` ✅
- `maui-pr-devicetests (net11.0 CoreCLR ios/catalyst/android Helix Tests
Build Device Tests (CoreCLR))` ❌

Each check links to the job's log and follows it (queued → in progress →
success / failure / cancelled) on every results sweep. Checks are tagged
`external_id: job:<build id>`; when a later `/review` run on the same
commit builds something else, the previous build's job checks that are
no longer part of it are marked neutral ("Superseded").

### Testing

- New Pester test for `New-RunTestsJobChecks`; `RunTests.Tests.ps1`
passes (76).
- Generated the checks from the live build 1698101 (#40550) — the 8
Android UITests jobs with their results.
- Creating check runs needs the GitHub App token, so the end-to-end
check happens in the workflow after merge.

Co-authored-by: Copilot CI <copilot-ci@microsoft.com>
Inside the Microsoft.Maui namespace, Android.Graphics resolves to
Microsoft.Android, which has no Graphics namespace, so the device test
project failed to build (CS0234). Use the GradientDrawable type from the
Android.Graphics.Drawables using directive that the file already has.

Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
@marcelomoresco

Copy link
Copy Markdown
Contributor Author

Resolved #ceca39ae — was a CS0234 (Android.Graphics.Drawables resolving ambiguously inside a Microsoft.* namespace, missing global::), not an actual test failure. Fixed, CI should be green now.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot 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.

Expert Review — 1 finding

Reviewed commit ceca39a.

See inline comments for details.

A solid BarBackground is applied as a tint on the toolbar's background
drawable. When the color is cleared and BarBackground becomes null, only the
view tint was cleared, so the drawable could keep the old color. Clear the
drawable tint on that path too, and test that clearing BarBackgroundColor
removes the previous color.

Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot 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.

Expert Review — 1 finding

Reviewed commit d7edf51.

See inline comments for details.

@marcelomoresco
marcelomoresco force-pushed the fix/40372-shell-toolbar-gradient-net11 branch from 291d2b6 to 627689d Compare November 25, 2026 16:48
Setting the view background tint to null still marks the tint as configured,
and Android then reapplies that empty tint to the background drawable. Only
clear the view tint and tint mode when they are set, so a solid color applied
to the drawable later is never cleared by a leftover view tint.
@marcelomoresco
marcelomoresco force-pushed the fix/40372-shell-toolbar-gradient-net11 branch from 627689d to 8733b74 Compare November 25, 2026 16:50
kubaflo added a commit that referenced this pull request Nov 25, 2026
…nchanged (#40615)

### Description of Change

Follow-up to #40612. Running `review-run-tests-results.yml` with
`head_sha` for #40550 found the two run-tests comments but published no
job checks: the builds had already finished, the comment text did not
change, and the loop skipped everything after the `$updated -ceq
$comment.body` check — including the check updates.

- The comment is only patched when it changed, but the `(selected run)`
check and the per-job checks are synced for every refreshed section.
- Comments are processed oldest first, so for one commit the newest
build's job checks win and the older build's extra jobs are marked
superseded.

### Testing

`RunTests.Tests.ps1` passes (76). After merge: re-dispatch
`review-run-tests-results.yml` with #40550's head SHA.
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…PR (dotnet#40612)

### Description of Change

`/review run-tests` builds run on a `run-tests/*` dispatch commit, so
Azure Pipelines reports their jobs on that commit and the PR's checks
panel only shows the `maui-pr-uitests (selected run)` /
`maui-pr-devicetests (selected run)` summary checks.

`Update-RunTestsResults.ps1` now mirrors every job of the selected build
as its own check on the PR head, e.g.

- `maui-pr-uitests (Android UITests CoreClr Controls (API 30) Shell1)` ✅
- `maui-pr-devicetests (net11.0 CoreCLR ios/catalyst/android Helix Tests
Build Device Tests (CoreCLR))` ❌

Each check links to the job's log and follows it (queued → in progress →
success / failure / cancelled) on every results sweep. Checks are tagged
`external_id: job:<build id>`; when a later `/review` run on the same
commit builds something else, the previous build's job checks that are
no longer part of it are marked neutral ("Superseded").

### Testing

- New Pester test for `New-RunTestsJobChecks`; `RunTests.Tests.ps1`
passes (76).
- Generated the checks from the live build 1698101 (dotnet#40550) — the 8
Android UITests jobs with their results.
- Creating check runs needs the GitHub App token, so the end-to-end
check happens in the workflow after merge.

Co-authored-by: Copilot CI <copilot-ci@microsoft.com>
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…nchanged (dotnet#40615)

### Description of Change

Follow-up to dotnet#40612. Running `review-run-tests-results.yml` with
`head_sha` for dotnet#40550 found the two run-tests comments but published no
job checks: the builds had already finished, the comment text did not
change, and the loop skipped everything after the `$updated -ceq
$comment.body` check — including the check updates.

- The comment is only patched when it changed, but the `(selected run)`
check and the per-job checks are synced for every refreshed section.
- Comments are processed oldest first, so for one commit the newest
build's job checks win and the older build's extra jobs are marked
superseded.

### Testing

`RunTests.Tests.ps1` passes (76). After merge: re-dispatch
`review-run-tests-results.yml` with dotnet#40550's head SHA.
@kubaflo

This comment has been minimized.

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Selected Tests

@kubaflo — AI-selected UI tests and device tests (GPT-6.2 Sol + MAI Code 2) for commit 8733b74c.

Result PASSED Platforms Android Tests 4 UI, 4 device Commit 8733b74c


🧪 Test selection — click to expand
Suite Result Selected Build
UI tests ✅ passed 4 of 77 categories maui-pr-uitests #1701009
Device tests ✅ passed 4 of 105 units maui-pr-devicetests #1701020
🧪 UI tests — Navigation, Shell1, Shell2, Material3 on Android

✅ maui-pr-uitests #1701009 passed.

GPT-6.2 Sol: Run Android Shell, Navigation, and Material3 UI tests for the toolbar background tint fix.
MAI Code 2: Android-only toolbar background tint fix; runs Shell and Navigation UI tests on Android.

🧪 Ran — 4 categories on Android

Platform Categories
Android Navigation, Shell1, Shell2, Material3
📊 Results — succeeded: 8 passed, 0 failed of 8 jobs

🔗 All test results · Build logs

Job Result
Android UITests CoreClr Controls (API 30) Navigation ✅ succeeded
Android UITests CoreClr Controls (API 30) Shell1 ✅ succeeded
Android UITests CoreClr Controls (API 30) Shell2 ✅ succeeded
Android UITests Material3 Controls Material3 (API 36) ✅ succeeded
Android UITests Shell Renderer Controls Shell Renderer (API 30) Shell1 ✅ succeeded
Android UITests Shell Renderer Controls Shell Renderer (API 30) Shell2 ✅ succeeded
Build UITests CoreCLR Sample App Build Sample App ✅ succeeded
Build UITests Material3 Sample App Build Sample App (Material3) ✅ succeeded
🧪 Device tests — Controls.Modal, Controls.NavigationPage, Controls.Shell, Controls.Toolbar on Android

✅ maui-pr-devicetests #1701020 passed.

GPT-6.2 Sol: Run Android NavigationPage, Shell, and Toolbar device tests for drawable tinting and background replacement.
MAI Code 2: Android toolbar tint behavior and its navigation and Shell call sites; runs focused Controls device tests on Android.

🧪 Ran — 4 categories on Android

Platform Categories
Android Controls.Modal, Controls.NavigationPage, Controls.Shell, Controls.Toolbar
📊 Results — succeeded: 2 passed, 0 failed of 2 jobs

🔗 All test results · Build logs

Job Result
net11.0 CoreCLR Android Helix Tests Run DeviceTests Android (CoreCLR) ✅ succeeded
net11.0 CoreCLR ios/catalyst/android Helix Tests Build Device Tests (CoreCLR) ✅ succeeded
⏭️ Skipped — what neither suite runs

UI tests — 73 categories, 3 platforms

Platforms not run: iOS, MacCatalyst, Windows

Categories not run: Accessibility, ActionSheet, ActivityIndicator, Animation, AppLinks, Border, BoxView, Brush, Button, CarouselView, CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7, Cells, CheckBox, ContextActions, CustomRenderers, DatePicker, Dispatcher, DisplayAlert, DisplayPrompt, DragAndDrop, Entry, Editor, Effects, Essentials, FlyoutPage, Focus, Fonts, Frame, Gestures, GraphicsView, Image, ImageButton, IndicatorView, InputTransparent, IsEnabled, IsVisible, Label, Layout, Lifecycle, ManualReview, Maps, Page, Performance, Picker, ProgressBar, RadioButton, RefreshView, SafeAreaEdges, Shadow, ScrollView, SearchBar, Shape, Slider, SoftInput, Stepper, Switch, SwipeView, TabbedPage, TableView, TimePicker, TitleView, ToolbarItem, Triggers, ViewBaseTests, VisualStateManager, Window, WebView

Each skipped platform and category is listed as a maui-pr-uitests (skipped) … status on this commit. Use /azp run maui-pr-uitests for the full suite.

Device tests — 101 categories, 3 platforms

Platforms not run: iOS, MacCatalyst, Windows

Categories not run: Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay, Graphics, Essentials, BlazorWebView

Each skipped platform and project is listed as a maui-pr-devicetests (skipped) … status on this commit. Use /azp run maui-pr-devicetests for the full suite.

🤖 Why these tests — AI rationale (GPT-6.2 Sol + MAI Code 2)

UI tests

Each model chose independently; every test that runs was selected by at least one of them.

Platform GPT-6.2 Sol MAI Code 2
Android Shell1, Shell2, Navigation, Material3 Shell1, Shell2, Navigation
iOS — —
MacCatalyst — —
Windows — —

GPT-6.2 Sol — Run Android Shell, Navigation, and Material3 UI tests for the toolbar background tint fix.

  • ToolbarExtensions.cs changes BarBackground rendering for Shell and NavigationPage on Android.
  • Material3 covers Shell’s native toolbar color capture.
  • No toolbar-item, navigation-stack, or non-Android changes.

MAI Code 2 — Android-only toolbar background tint fix; runs Shell and Navigation UI tests on Android.

  • ToolbarExtensions.cs changes Android toolbar tint application used by Shell, so run Shell on Android.
  • The same toolbar path controls NavigationPage.BarBackground, so run Navigation on Android.
  • The code is Android-specific and narrowly scoped; omit iOS, Mac Catalyst, Windows, and unrelated UI categories.
  • This is not a base layout or app-infrastructure change, so no full run is needed.

Device tests

Each model chose independently; every test that runs was selected by at least one of them.

Platform GPT-6.2 Sol MAI Code 2
Android Controls.NavigationPage, Controls.Shell, Controls.Toolbar Controls.NavigationPage, Controls.Modal, Controls.Shell
iOS — —
MacCatalyst — —
Windows — —

GPT-6.2 Sol — Run Android NavigationPage, Shell, and Toolbar device tests for drawable tinting and background replacement.

  • NavigationPageTests.Android.cs adds regressions for replacing a tinted background and clearing BarBackgroundColor.
  • Controls.Shell and Controls.Toolbar cover consumers of the changed Android toolbar rendering.
  • No Core handler, modal-stack, or non-Android changes.

MAI Code 2 — Android toolbar tint behavior and its navigation and Shell call sites; runs focused Controls device tests on Android.

  • ToolbarExtensions.cs changes Android NavigationPage/Shell toolbar background handling, selecting Controls.NavigationPage and Controls.Shell.
  • Navigation styling is coupled to modal toolbar behavior, so include Controls.Modal.
  • The modified device tests target Android NavigationPage background tint regressions.
  • No shared base class, app startup, Core handler, or other platform is affected; no full device run is needed.

Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification.

@kubaflo
kubaflo changed the base branch from net11 to candidate/11.0.1xx-sr3 November 26, 2026 18:22
@kubaflo
kubaflo merged commit aa55172 into dotnet:candidate/11.0.1xx-sr3 Nov 26, 2026
132 of 135 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-shell Shell Navigation, Routes, Tabs, Flyout community ✨ Community Contribution platform/android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] Shell toolbar renders custom gradient background as a solid color due to leftover BackgroundTintList — still reproduces on .NET 10

2 participants