在我的Xamarin.Forms应用程序中,底部有一个按钮。此按钮隐藏在Windows 10移动电话上。难道没有一个设置是我的页面大小适应可用的大小吗?在这种情况下,如果显示导航条,我的页面的高度会降低,如果导航栏被隐藏,则会增加。
我看到了一些解决方案,建议将导航栏隐藏起来。例如。
ApplicationView.GetForCurrentView().TryEnterFullScreenMode();它应该放在哪里?我把它放在App.xaml.cs之前,rootFrame.Navigate放在OnLaunched里。如果我在本地机器上运行这个应用程序,它就会变成全屏。在手机上,导航栏是隐藏的,但底部还有一个白色的区域。
而且我试过了
ApplicationView.GetForCurrentView().FullScreenSystemOverlayMode = FullScreenSystemOverlayMode.Minimal;但我没看到什么不同的东西。
开发人员应该如何处理导航栏而不隐藏其下面的内容?
发布于 2016-03-24 12:15:31
这似乎解决了这个问题:
ApplicationView.GetForCurrentView().SuppressSystemOverlays = true;结果是,在启动应用程序时,导航栏没有显示。用户可以通过滑动显示导航条。在这里,页面会根据需要自动调整大小。
我把它放在App.xaml.cs中的OnLaunched方法中:
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
Xamarin.Forms.Forms.Init(e);
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
ApplicationView.GetForCurrentView().SuppressSystemOverlays = true;
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}发布于 2017-03-24 08:27:47
您还可以使用:
ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible);在UWP的App.xaml.cs文件中,onLauched函数如下所示:
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
Xamarin.Forms.Forms.Init(e);
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible);
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}这将确保您的应用程序停留在可见区域内,因此没有覆盖从底部导航栏。
https://stackoverflow.com/questions/36182639
复制相似问题