XAML 如何将底部导航与xamarin shell标签栏中的内容重叠

dxxyhpgq  于 2022-12-16  发布在  Shell
关注(0)|答案(1)|浏览(210)
[assembly: ExportRenderer(typeof(AppShell), typeof(CustomShellRenderer))]
namespace App4.Droid
{
    public class CustomShellRenderer : ShellRenderer
    {
         public CustomShellRenderer(Context context) : base(context)
         {
         }

         protected override IShellBottomNavViewAppearanceTracker CreateBottomNavViewAppearanceTracker(ShellItem shellItem)
         {
             return new CustomShellBottomNavViewAppearanceTracker();
         }
     }

     public class CustomShellBottomNavViewAppearanceTracker : IShellBottomNavViewAppearanceTracker
     {
         public void Dispose()
         {
         }

         public void ResetAppearance(BottomNavigationView bottomView)
         {
         }

         public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance)
         {
             (bottomView.Parent as LinearLayout)?.SetBackgroundColor(Color.Transparent.ToAndroid());

              bottomView.SetBackgroundColor(Color.Transparent.ToAndroid());
              bottomView.LabelVisibilityMode = LabelVisibilityMode.LabelVisibilityUnlabeled;
         }
     }
}

shell自定义渲染器在android中
我想将内容部分和底部导航部分重叠
我知道如何在没有shell和CustomRender的情况下实现纯XAML,但我不想这样做,因为我的项目高度依赖于Shell
例如)

https://github.com/naweed/MauiPlanets
上面的应用程序是重叠底部导航和内容页面在我的情况下删除标签栏背景和保留图标简单地说,我想降低与底部导航重叠的内容页面的高度。

aoyhnmkz

aoyhnmkz1#

如果我没理解错的话,全屏应该能满足你的需要。
将此添加到您的MainActivity.cs

protected override void OnCreate(Bundle savedInstanceState)
{
    ...

    IWindowInsetsController wicController = Window.InsetsController;
    Window.SetDecorFitsSystemWindows(false);
    Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

    if (wicController != null)
    {
       wicController.Hide(WindowInsets.Type.NavigationBars());
    }
           
}

相关问题