Shell Navigation Bar Scroll Behavior
I would like to ask if it is possible to animate the Navigation Bar or TabbedPage (TabLayout) in the Xamarin.Forms Shell when scrolling it either hides or the discovery see gif. I
Solution 1:
Not sure if you can achieve this behavior with an android style in XF + Shell, but you can achieve it using a custom renderer by overriding CreateToolbarAppearanceTracker()
.
publicclassMyShellRenderer : ShellRenderer
{
publicMyShellRenderer(Context context) : base(context)
{
}
protectedoverride IShellToolbarAppearanceTracker CreateToolbarAppearanceTracker()
{
base.CreateToolbarAppearanceTracker();
returnnew MyShellToolbarAppearanceTracker(this);
}
}
MyShellToolbarAppearanceTracker (name it whatever you want)
using LP = Android.Views.ViewGroup.LayoutParams;
...
publicclassMyShellToolbarAppearanceTracker : ShellToolbarAppearanceTracker
{
publicMyShellToolbarAppearanceTracker(IShellContext shellContext) : base(shellContext)
{
}
publicoverridevoidSetAppearance(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
};
}
}
Don't forget to properly decorate it with ExportRenderer
as explained in the documentation.
(ignore this section if the below linked bug/issue is closed)
Known Side-Effect
This is a trivial undesired side-effect caused by a Xamarin.Forms Bug 13338
Post a Comment for "Shell Navigation Bar Scroll Behavior"