Xamarin Forms NavigationBar的左边距是

问题描述 投票:0回答:1

我有问题。我这样创建了一个TabbedPage:

TabbedBuilder = new TabbedPage
{
    BarBackgroundColor = Color.FromHex("#212121"),
    BarTextColor = Color.White
};

TabbedBuilder.Children.Add(new NavigationPage(new Builder())
{ 
    Title = "Builder",
    BarBackgroundColor = Color.FromHex("#212121")
});
TabbedBuilder.Children.Add(new NavigationPage(new TemplateList())
{
    Title = "Templates",
    BarBackgroundColor = Color.FromHex("#212121")
});

我这样称呼它:

Navigation.PushModalAsync(TabbedBuilder);

现在在TabbedBuilder中,我具有此自定义导航栏:

<NavigationPage.TitleView>
    <StackLayout Orientation="Vertical" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
        <StackLayout VerticalOptions="CenterAndExpand" Orientation="Horizontal" BackgroundColor="#212121">
            <ImageButton Source="Back_Dark.png" HeightRequest="25" WidthRequest="35" HorizontalOptions="Start"
                VerticalOptions="Center" BackgroundColor="Transparent" Clicked="btnBack_Clicked"/>
            <Image Source="Title_Dark.png" HeightRequest="25" HorizontalOptions="CenterAndExpand" VerticalOptions="Center"/>
        </StackLayout>
        <StackLayout VerticalOptions="End" HorizontalOptions="FillAndExpand">
            <Label HeightRequest="1" BackgroundColor="White" HorizontalOptions="Fill"/>
        </StackLayout>
    </StackLayout>
</NavigationPage.TitleView>

但是左侧边距很小!

我该如何删除?

c# xamarin xamarin.forms xamarin.android xamarin.ios
1个回答
-1
投票

您已经在xaml中的ImageButton上设置了Margin

               VerticalOptions="Center" Margin="5,0,0,0" BackgroundColor="Transparent" Clicked="btnBack_Clicked"/>

将其更改为:

               VerticalOptions="Center" BackgroundColor="Transparent" Clicked="btnBack_Clicked"/>
© www.soinside.com 2019 - 2024. All rights reserved.