1
votes

This is my first time using navigation title view. The issue I have is the background of the navigation bar in Android is different from the one in iOS. I want to set the color of the background to white so it's the same for both iOS and Android. Any suggestions how to do it. I have included the code and images below

XAML code

    <NavigationPage.TitleView>
    <Label           FontSize="25"
                     TextColor="Black"
                     VerticalOptions="CenterAndExpand"
                     HorizontalOptions="CenterAndExpand"
                     HorizontalTextAlignment="Center"
                     FontFamily="PatrickFont">
                <Label.FormattedText>
                    <FormattedString>
                        <Span Text="Number"/>
                        <Span Text="Generator" TextColor="Red"/>
                    </FormattedString>
                </Label.FormattedText>
            </Label>
</NavigationPage.TitleView>

CS code

private void InfoIconCommandExecute(object obj)
{
   App.Current.MainPage.Navigation.PushAsync(new InfoPage());
}

enter image description here

enter image description here

1

1 Answers

4
votes

Option 1. Setting the navigation page color in your app.xaml file. This will affect all pages in your app.

...
<Application.Resources>
   <Style TargetType="NavigationPage">
      <Setter Property="BarBackgroundColor" Value="White"/>
      <Setter Property="BarTextColor" Value="OrangeRed" />
   </Style>
</Application.Resources>
...

Option 2. Setting in the page file you want to change the navigation background color. YourPage.xaml.cs

...
public YourPage()
{
   InitializeComponent();
   ((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.White;
   ((NavigationPage)Application.Current.MainPage).BarTextColor = Color.OrangeRed;
}
...