问题
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