Maui修改状态栏导航栏颜色

Maui修改状态栏导航栏颜色

  1. colors.xml文件中添加style

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    
    <resources>
        <color name="colorPrimary">#512BD4</color>
        <color name="colorPrimaryDark">#2B0B98</color>
        <color name="colorAccent">#2B0B98</color>
    
        <style name="SplashTheme" parent="@style/Maui.SplashTheme">
            <item name="android:statusBarColor">@android:color/black</item>
            <item name="android:navigationBarColor">@android:color/black</item>
        </style>
    </resources>
    
  2. MainActivity.cs(Platforms/Android)文件中修改主题。

    1
    2
    3
    4
    5
    
    [Activity(
        //Theme = "@style/Maui.SplashTheme",
        Theme = "@style/SplashTheme",
        MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)]
    public class MainActivity : MauiAppCompatActivity
    
Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy