我有 .Net 7 Maui 应用程序。
当应用程序从 Visual Studio 部署到物理设备时,顶部栏的颜色设置正确。
然而,当完全相同的项目应用程序发布到 Play 商店时,顶部栏颜色不同。
这是完全相同的项目。
有人知道怎么解决吗?
从 Visual Studio 部署到物理设备的应用程序:正确的颜色
从 Play 商店下载的已发布应用:颜色不正确
这里是如何设置颜色的:
在Resources/styles/colors.xml:
<Color x:Key="LightModePageBarColor">#799ff6</Color>
在app_shell.xml中:
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="MyProject.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MyProject"
BackgroundColor="{StaticResource LightModePageBarColor}">
... shell content
</Shell>
在Resources/styles/styles.xml:
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="{AppThemeBinding Light={StaticResource LightModePageBarColor}, Dark={StaticResource DarkModePageBarColor}}" />
</Style>