首页 > 解决方案 > Xamarin Forms:如何将 contentPage 工具栏图像居中对齐?

问题描述

我通过以下代码向工具栏添加了一个图标,但是如何将其对齐到中心。现在它在右端。在这个线程中告诉它在 xamarin 形式中是不可能的。

<ContentPage.ToolbarItems>
    <ToolbarItem Icon="logo-final.jpg"/>
</ContentPage.ToolbarItems>

我需要屏幕下方的中心图标。

在此处输入图像描述

请为此功能提出解决方案?

标签: xamarin.formstoolbarcenter

解决方案


您应该尝试导航标题视图

<ContentPage>
    <NavigationPage.TitleView>
        <StackLayout Orientation="Horizontal" VerticalOptions="Center" Spacing="10">
            <Image Source="iconXamagon.png">               
            </Image>           
        </StackLayout>
    </NavigationPage.TitleView>
    ...
</ContentPage>

如需更多参考 https://montemagno.com/xamarin-forms-icons-in-navigation-toolbar/


推荐阅读