Appshell NavBar and TabBar not work fine in Android(Using Xamarin.forms)

Yao, LiCheng 0 Reputation points
2023-06-16T08:14:10.2666667+00:00

I want set Appshell NavBar and TabBar Invisible when Device is Horizontal and visible when Vertical.

I code like following , it works fine in IOS, but when Android device changed to Horizontal, the object on NavBar and TabBar is disappeared and both of bar is still there and TabBar become black.

I think the page refresh event is quick than OnSizeAllocated, but I don't know how to refresh page again after by code.

Please help me!

        protected override void OnSizeAllocated(double width, double height)
        {
            //When device is rotated to Horizontal, change legend orientation
            if (this.Width > this.Height)
            {  //Horizontal
                AppShell.SetNavBarIsVisible(this, false);
                AppShell.SetTabBarIsVisible(this, false);
            }
            else
            {  //Vertical
                AppShell.SetNavBarIsVisible(this, true);
                AppShell.SetTabBarIsVisible(this, true);
            }
            base.OnSizeAllocated(width, height);
        }
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,376 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.