在Android上隐藏TabbedPage所选项目的标签或调整标签文本

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

我在选项卡式页面上遇到了一些麻烦,我的客户的要求是在选项卡式页面项目中显示所有标签,但是正如您在印刷品中看到的那样,标签不合适?

Print1

Print2

Goal

目标是使所有标签都适合第三个打印屏幕中的标签,或者仅隐藏所选项目的标签。

PS:我正在使用自定义效果来禁用选项卡式页面的移位模式,这是代码:

[assembly: ResolutionGroupName("Fullware")]
[assembly: ExportEffect(typeof(NoShiftEffect), "NoShiftEffect")]
namespace SincorSPM.Droid
{
    public class NoShiftEffect : PlatformEffect
    {
        protected override void OnAttached()
        {
            if (!(Container.GetChildAt(0) is ViewGroup layout))
                return;

            if (!(layout.GetChildAt(1) is BottomNavigationView bottomNavigationView))
                return;

            // This is what we set to adjust if the shifting happens
            bottomNavigationView.LabelVisibilityMode = LabelVisibilityMode.LabelVisibilityLabeled;
        }



        protected override void OnDetached()
        {
        }
    }
}

编辑//

请求的TabbedPage XAML

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
             android:TabbedPage.ToolbarPlacement="Bottom"
            android:TabbedPage.IsSmoothScrollEnabled="True"
             xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
             ios:Page.UseSafeArea="true"
            BarBackgroundColor="#032e5c"
            BarTextColor="#e27900"
            xmlns:lottie="clr-namespace:Lottie.Forms;assembly=Lottie.Forms"
            SelectedTabColor="#009fe2"
             xmlns:Helpers="clr-namespace:SincorSPM"
            xmlns:pancake="clr-namespace:Xamarin.Forms.PancakeView;assembly=Xamarin.Forms.PancakeView"
             UnselectedTabColor="#e27900"
             xmlns:local="clr-namespace:SincorSPM;assembly=SincorSPM"
             x:Class="SincorSPM.Main.TabbedMain">

   <TabbedPage.Resources>
        <ResourceDictionary>

            <Color x:Key="BackgroundColor">#032e5c</Color>
            <Color x:Key="ButtonColor">#286d9f</Color>
            <Color x:Key="ButtonTextColor">#ffffff</Color>
            <Color x:Key="TitlesColor">#b99559</Color>

            <!-- Font Size -->

        </ResourceDictionary>
    </TabbedPage.Resources>
    <TabbedPage.Effects>
        <local:NoShiftEffect />
    </TabbedPage.Effects>

   //Content Pages

</TabbedPage>
c# xamarin.forms xamarin.android
1个回答
0
投票

我从Montemagno博客获得了解决方案,使用Resources / value / dimens.xml,我可以通过这种方式更改文本大小:

© www.soinside.com 2019 - 2024. All rights reserved.