摆脱 Xamarin 表单中的默认蓝色
get rid of default blue in Xamarin forms
我有一个 Xamarin 表单项目,我不知道如何去掉背景中的默认蓝色。我在 app.xaml 中更改了资源字典中的原色。它在各个页面上运行良好,但它们在背景中仍然有些蓝色(请参阅所附的屏幕截图),我也需要更改。
提前致谢
<Application.Resources>
<ResourceDictionary>
<Color x:Key="Primary">BurlyWood</Color>
<Style TargetType="Button">
<Setter Property="BorderRadius" Value="15"/>
<Setter Property="BorderWidth" Value="2"/>
<Setter Property="BorderColor" Value="{StaticResource Primary}"/>
<Setter Property="TextColor" Value="{StaticResource Primary}"></Setter>
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="White" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="#332196F3" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
</ResourceDictionary>
</Application.Resources>
enter image description here
enter image description here
有两个酒吧。导航栏和状态栏。
对于导航栏,在 ResourceDictionary
标签
内添加此代码
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="White" />
<Setter Property="BarTextColor" Value="Black" />
</Style>
或者,将这两行添加到 MainPage.xaml.cs
文件的构造函数中
BarBackgroundColor = Color.White;
BarTextColor = Color.Black;
对于 StatusBar,请遵循以下 link 说明:
Android:
IoS: Click Here
我有一个 Xamarin 表单项目,我不知道如何去掉背景中的默认蓝色。我在 app.xaml 中更改了资源字典中的原色。它在各个页面上运行良好,但它们在背景中仍然有些蓝色(请参阅所附的屏幕截图),我也需要更改。 提前致谢
<Application.Resources>
<ResourceDictionary>
<Color x:Key="Primary">BurlyWood</Color>
<Style TargetType="Button">
<Setter Property="BorderRadius" Value="15"/>
<Setter Property="BorderWidth" Value="2"/>
<Setter Property="BorderColor" Value="{StaticResource Primary}"/>
<Setter Property="TextColor" Value="{StaticResource Primary}"></Setter>
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="White" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="#332196F3" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
</ResourceDictionary>
</Application.Resources>
enter image description here
enter image description here
有两个酒吧。导航栏和状态栏。
对于导航栏,在 ResourceDictionary
标签
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="White" />
<Setter Property="BarTextColor" Value="Black" />
</Style>
或者,将这两行添加到 MainPage.xaml.cs
文件的构造函数中
BarBackgroundColor = Color.White;
BarTextColor = Color.Black;
对于 StatusBar,请遵循以下 link 说明:
Android:
IoS: Click Here