Shell navigation bottom and upper TabBar scroll behavior

≡放荡痞女 提交于 2021-01-28 02:39:16

问题


In follow-up of Shell navigation bar scroll behavior, I have created a custom Shell renderer toolbar with scroll behavior and I would like to know if it is possible to create the same for TabBar or Tab in Shell. See Gif

https://android.jlelse.eu/scroll-your-bottom-navigation-view-away-with-10-lines-of-code-346f1ed40e9e

 using LP = Android.Views.ViewGroup.LayoutParams;
 public class CustomShell : ShellRenderer
{
    public CustomShell(Context context) : base(context) { }
    protected override IShellToolbarAppearanceTracker CreateToolbarAppearanceTracker()
    {
        base.CreateToolbarAppearanceTracker();
        return new MyShellToolbarAppearanceTracker(this);
    }
}

public class MyShellToolbarAppearanceTracker : ShellToolbarAppearanceTracker
{
    public MyShellToolbarAppearanceTracker(IShellContext shellContext) : base(shellContext)
    {
    }

    public override void SetAppearance(AndroidX.AppCompat.Widget.Toolbar toolbar, IShellToolbarTracker toolbarTracker, ShellAppearance appearance)
    {
        base.SetAppearance(toolbar, toolbarTracker, appearance);

        toolbar.LayoutParameters = new AppBarLayout.LayoutParams(LP.MatchParent, LP.WrapContent)
        {
            ScrollFlags = AppBarLayout.LayoutParams.ScrollFlagScroll |
                          AppBarLayout.LayoutParams.ScrollFlagEnterAlways,
        };
    }
}

AppShell.xaml

 <FlyoutItem Title="Home" 
        FlyoutIcon="{StaticResource FontIconHome}"
        FlyoutDisplayOptions="AsSingleItem">
<Tab Title="Home"
     Icon="{StaticResource FontIconHome}">
       <ShellContent Route="HomePage" ContentTemplate="{DataTemplate homepage:HomePage}" />
</Tab>
<Tab Title="Download"
     Icon="{StaticResource FontIconDownLoad}">
    <ShellContent Route="DownloadPage" ContentTemplate="{DataTemplate downloadpage:DownloadPage}" />
</Tab>

来源:https://stackoverflow.com/questions/65649410/shell-navigation-bottom-and-upper-tabbar-scroll-behavior

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!