Forum Xamarin.Forms

Navigation Title not centering on Android

Conor.MurphyConor.Murphy GBMember ✭✭
edited October 2019 in Xamarin.Forms

I’ve set the navigation title in my Xamarin forms application as below:

            <Label Text="Settings" Style="{StaticResource NavTitle}"/>
            <Button Text="&#xf060;" Style="{StaticResource LeftNavButton}" Clicked="BackButtonClicked"/>

The Label has been centered, on iOS the positioning is fine but on Android it is shifted over to the right. I've set the navigation back button to be hidden with NavigationPage.SetHasBackButton(this, false) but it seems to still be pushing it over, does anybody have any insight to why it's shifted over on Android and not iOS?

Images attached, Thanks in advance!

Below is the styles for reference:

         <Style x:Key="LeftNavButton" TargetType="Button">
            <Setter Property="BackgroundColor" Value="Transparent"/>
            <Setter Property="TextColor" Value="White"/>
            <Setter Property="HeightRequest" Value="20"/>
            <Setter Property="FontSize" Value="20"/>
            <Setter Property="FontFamily" Value="{StaticResource FontAwesomeSolid}"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="HorizontalOptions" Value="Start"/>
            <Setter Property="WidthRequest" Value="30"/>
            <Setter Property="Margin" Value="{StaticResource LeftButtonMargin}"/>

        <Style x:Key="NavTitle" TargetType="Label">
            <Setter Property="FontAttributes" Value="Bold"/>
            <Setter Property="TextColor" Value="White"/>
            <Setter Property="HeightRequest" Value="20"/>
            <Setter Property="FontSize" Value="17"/>
            <Setter Property="VerticalTextAlignment" Value="Center"/>
            <Setter Property="HorizontalTextAlignment" Value="Center"/>
            <Setter Property="HorizontalOptions" Value="CenterAndExpand"/>
            <Setter Property="VerticalOptions" Value="CenterAndExpand"/>

Best Answer


  • Conor.MurphyConor.Murphy GBMember ✭✭

    Images attached

  • ssamixssamix Member ✭✭✭

    it is not working , something wrong?

  • CytophCytoph Member ✭✭

    @ssamix said:
    it is not working , something wrong?

    Same problem for me. This workaround does not seem to work anymore. Ideas anyone?

Sign In or Register to comment.