Share via

How to Modify the status bar color in the android maui .net 10

Vaibhav Methuku (ext) 0 Reputation points
2026-04-14T04:32:55.13+00:00

We are working on a .NET 10 MAUI application that uses AppShell. In the application, we want to update the status bar color dynamically based on the currently active page. How can we achieve this within the application?

Facing this in the android 10.

Developer technologies | .NET | .NET MAUI

2 answers

Sort by: Most helpful
  1. Nancy Vo (WICLOUD CORPORATION) 2,655 Reputation points Microsoft External Staff Moderator
    2026-04-14T09:46:13.1766667+00:00

    Hello @Vaibhav Methuku (ext) ,

    Thanks for your question.

    I tested on my device and it works. Please try again with StatusBarBehavior. You can refer to my following steps:

    Step 1: Install latest community toolkit

    • Right-click your project → click Manage NuGet Packages -> CLick Browser tab -> Find CommunityToolkit.Maui and install.
    • Or you can enter this in terminal: dotnet add package CommunityToolkit.Maui

    Step 2: Register community toolkit Open MauiProgram.cs and update it:

    using CommunityToolkit.Maui;  // ← ADD THIS LINE
    using Microsoft.Extensions.Logging;
    
    namespace YourProjectName  // ← Your project name
    {
        public static class MauiProgram
        {
            public static MauiApp CreateMauiApp()
            {
                var builder = MauiApp.CreateBuilder();
                builder
                    .UseMauiApp<App>()
                    .UseMauiCommunityToolkit()  // ← ADD THIS LINE
                    .ConfigureFonts(fonts =>
                    {
                        fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                        fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
                    });
    
    #if DEBUG
                builder.Logging.AddDebug();
    #endif
    
                return builder.Build();
            }
        }
    }
    

    Step 3: Add Namespace to App.xaml

    Open App.xaml and add the toolkit namespace

    <?xml version="1.0" encoding="UTF-8" ?>
    <Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:local="clr-namespace:YourProjectName"
                 xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
                 x:Class="YourProjectName.App">
        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="Resources/Styles/Colors.xaml" />
                    <ResourceDictionary Source="Resources/Styles/Styles.xaml" />
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </Application.Resources>
    </Application>
    

    Key change: xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"

    Step 4: Change status bar color in AppShell.xaml Open AppShell.xaml and add the StatusBarBehavior:

    <?xml version="1.0" encoding="UTF-8" ?>
    <Shell
        x:Class="YourProjectName.AppShell"
        xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        xmlns:local="clr-namespace:YourProjectName"
        xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
        Shell.FlyoutBehavior="Disabled"
        Title="YourProjectName">
    
         <TabBar>
         <ShellContent
             Title="Home"
             Icon="home.png"
             ContentTemplate="{DataTemplate local:HomePage}"
             Route="HomePage" />
    
         <ShellContent
             Title="Profile"
             Icon="profile.png"
             ContentTemplate="{DataTemplate local:ProfilePage}"
             Route="ProfilePage" />
    
         <ShellContent
             Title="Settings"
             Icon="settings.png"
             ContentTemplate="{DataTemplate local:SettingsPage}"
             Route="SettingsPage" />
    </TabBar>
    
    </Shell>
    

    And in every page, you change the color: For ex: in HomePage.xaml

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
                 x:Class="TestStatusBar.HomePage"
                 Title="Home">
    
        <ContentPage.Behaviors>
            <toolkit:StatusBarBehavior StatusBarColor="Red" StatusBarStyle="LightContent" />
        </ContentPage.Behaviors>
    
        <VerticalStackLayout Padding="30" Spacing="25">
            <Label
                Text="Welcome to HomePage"
                FontSize="24"
                HorizontalOptions="Center" />
        </VerticalStackLayout>
    
    </ContentPage>
    

    Step 5: Build and run

    dotnet clean
    dotnet build
    

    I hope this addresses your question. If this response was helpful, please consider following the guidance to provide feedback.

    0 comments No comments

  2. Q&A Assist
    2026-04-14T04:33:10.6066667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Use the .NET MAUI Community Toolkit StatusBarBehavior (or its underlying APIs) and apply it per page so the status bar color changes when navigation occurs.

    1. Add the CommunityToolkit.Maui package and initialize it in your MAUI app (per toolkit docs).
    2. In each page where the status bar color must change, attach StatusBarBehavior and set ApplyOn so it runs when the page becomes active.

    Example XAML setup (per-page):

    <ContentPage
        xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
        x:Class="MyApp.Pages.HomePage">
    
        <ContentPage.Behaviors>
            <toolkit:StatusBarBehavior
                ApplyOn="OnPageNavigatedTo"
                StatusBarColor="Red"
                StatusBarStyle="LightContent" />
        </ContentPage.Behaviors>
    
        <!-- Page content here -->
    
    </ContentPage>
    

    Key points from the behavior:

    • StatusBarColor sets the bar color using Microsoft.Maui.Graphics.Color.
    • StatusBarStyle can be LightContent, DarkContent, or Default.
    • ApplyOn="OnPageNavigatedTo" ensures the status bar is updated when navigation lands on that page, which is recommended when changing appearance per page so the system does not keep the color from the previous page.

    If using C# instead of XAML for a page:

    using CommunityToolkit.Maui.Behaviors;
    using CommunityToolkit.Maui.Core;
    
    class HomePage : ContentPage
    {
        public HomePage()
        {
            Behaviors.Add(new StatusBarBehavior
            {
                ApplyOn = StatusBarApplyOn.OnPageNavigatedTo,
                StatusBarColor = Colors.Red,
                StatusBarStyle = StatusBarStyle.LightContent
            });
        }
    }
    

    For more direct control (e.g., reacting to runtime conditions inside a page), call the platform API in OnNavigatedTo:

    using CommunityToolkit.Maui.Core;
    
    class DetailsPage : ContentPage
    {
        protected override void OnNavigatedTo(NavigatedToEventArgs args)
        {
            base.OnNavigatedTo(args);
    
            // Example: choose color dynamically
            var statusBarColor = Colors.Blue; // compute based on state
    
            Platform.StatusBar.SetColor(statusBarColor);
            Platform.StatusBar.SetStyle(StatusBarStyle.LightContent);
        }
    }
    

    Note: The toolkit warns against calling these APIs directly from MainPage constructor, OnAppearing, or OnNavigatedTo before platform components are initialized; in those cases prefer StatusBarBehavior so it safely hooks into the lifecycle.

    On Android, the underlying implementation ultimately calls into the platform’s status bar APIs (similar to Window.SetStatusBarColor), so this approach works on Android 10 and later as long as the app window is configured normally.

    When using AppShell, each ContentPage that is a Shell page (via ShellContent) can have its own StatusBarBehavior, and the correct color will be applied as the user navigates between Shell pages.


    References:

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.