1

为我的应用创建标题面板的最佳方式是什么?我想要这样的东西: app_example

我需要将我的应用程序图标和名称放在那里,而不是“ChrunchifyCalculator”。

这是我的解决方案结构: solution_structure

我应该使用来自 testHeader.Android -> Resources 的 Toolbar.xml 还是不是正确的方法?

4

1 回答 1

1

您可以使用自定义工具栏NavigationPage.TitleView。您甚至可以从 Droid 项目的资源文件中添加标题栏(状态栏)。

使用以下代码段添加自定义标题。


<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             .
             .
             .>

    <NavigationPage.TitleView>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="2*"/>
                <ColumnDefinition Width="8*"/>
            </Grid.ColumnDefinitions>
            <Icon source="YOUR_ICON.png" Grid.Column="0"/>
            <Label Grid.Column="1" Text="APP_NAME" TextColor="#ffffff" FontSize="Large" HorizontalOptions="Center" HorizontalTextAlignment="Center" FontAttributes="Bold"/>
        </Grid>
    </NavigationPage.TitleView>

    <ContentPage.Content>

              <-- YOUR XAML CODE -->

    </ContentPage.Content>
</ContentPage>

于 2020-08-25T15:42:56.107 回答