XAML 如何使TabBar标签的标题文本居中?

bksxznpy  于 2022-12-07  发布在  其他
关注(0)|答案(1)|浏览(203)

这是一个后续问题,我在Shell Custom Renderer reset color set by TabBarUnselectedColor中使用自定义渲染器
在我的.Net MAUI应用程序中,我在AppShell中使用了TabBar

<TabBar>
        <Tab Title="Home" Icon="{StaticResource IconHome}">
            <ShellContent ContentTemplate="{DataTemplate local:MainPage}" />
        </Tab>
        <Tab Title="Coverage&#10;Calculator" Icon="{StaticResource IconCalculator}" >
            <ShellContent ContentTemplate="{DataTemplate calculator:CoverageCalculatorPage}" />
        </Tab>
        <Tab Title="Distributor&#10;Locator" Icon="{StaticResource IconLocator}">
            <ShellContent ContentTemplate="{DataTemplate locator:DistributorsLocatorPage}" />
        </Tab>
        <Tab Title="Scan&#10;QR Code" Icon="{StaticResource IconQrScanner}">
            <ShellContent ContentTemplate="{DataTemplate qrScanner:QrScannerPage}" />
        </Tab>        
        <Tab Title="More" Icon="{StaticResource IconMore}">
            <ShellContent ContentTemplate="{DataTemplate more:MoreFeaturesPage}" />
        </Tab>
    </TabBar>

选项卡的标题是左对齐的。它们可以居中吗?
目前,它看起来像这样:

ecbunoof

ecbunoof1#

您可以设定TextView的对齐方式:

using TextAlignment = Android.Views.TextAlignment;
smallTextView.TextAlignment = TextAlignment.Center;

相关问题