使用超过 3 个选项卡后,TabbedPage 并不总是显示选项卡的标签

TabbedPage don't always display tab's labels after more than 3 tabs used

我得到这个用于我的导航:

     <TabbedPage ....

       <TabbedPage.Children>
            <NavigationPage Title=" MY_TITLE_1 ">
                <NavigationPage.Icon>
                    <OnPlatform x:TypeArguments="FileImageSource">
                        <On Platform="Android" Value="icon1.png" />
                        <On Platform="iOS" Value="icon1.png" />
                    </OnPlatform>
                </NavigationPage.Icon>
            </NavigationPage>
            <NavigationPage Title=" MY_TITLE_2 ">
   ....
     </TabbedPage>

问题是,当我放置 4 或 5 个选项卡时,我的文本被隐藏了,我需要单击选项卡才能看到文本(换句话说,我只能看到选项卡的文本点击 ).

在 iOS 中,文本始终可见。 有什么方法可以在 Android 中实现吗?

已解决:这篇文章对我有用。解决方案是关闭移动。

https://montemagno.com/xamarin-forms-fully-customize-bottom-tabs-on-android-turn-off-shifting/

综上所述,我更新了

Xamarin.Android.Support.Core.Utils, Xamarin.Android.Support.CustomTabs, Xamarin.Android.Support.Design, Xamarin.Android.Support.v4, Xamarin.Android.Support.v7.AppCombat, Xamarin.Android.Support.7.cardView, Xamarin.Android.Support.v7.MediaRouter

我在Android解决方案中制作了这个文件:

  using Android.Support.Design.BottomNavigation;
using Android.Support.Design.Widget;
using Android.Views;
using App16.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly:ResolutionGroupName ("MyCompany")]
[assembly:ExportEffect (typeof(NoShiftEffect), "NoShiftEffect")]
namespace App16.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 ()
        {
        }
    }
}

在共享解决方案中:

    using Xamarin.Forms;

namespace App16
{
    public class NoShiftEffect : RoutingEffect
    {
        public NoShiftEffect() : base("MyCompany.NoShiftEffect")
        {
        }
    }
}

这在我的 XAML:

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