[英]Hide 3 Bottom Buttons (Back/Home/Recent) (Android full screen)
I am developing an app for price verification on an Android device (OS version 7.1.2, API Level 25) using .NET MAUI RC3.我正在使用 .NET MAUI RC3 在 Android 设备(操作系统版本 7.1.2,API 级别 25)上开发价格验证应用程序。
I have managed to make the status bar at the top disappear, as well as the .NET MAUI navigation bar, using Shell.NavBarIsVisible="False", however, I'm stuck at trying to disable the Android navigation bar at the bottom:我已经设法使用 Shell.NavBarIsVisible="False" 使顶部的状态栏以及 .NET MAUI 导航栏消失,但是,我一直试图禁用底部的 Android 导航栏:
I have tried:我努力了:
I have set this in the MainActivity, but it only removes the status bar at the top:我在 MainActivity 中设置了这个,但它只删除了顶部的状态栏:
public class MainActivity : MauiAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
this.Window.AddFlags(Android.Views.WindowManagerFlags.Fullscreen);
}
}
The examples I found for hiding the navigation buttons all fail with syntax errors for various reasons:我发现的隐藏导航按钮的示例都因各种原因而因语法错误而失败:
Any help would be appreciated.任何帮助,将不胜感激。
Thanks,谢谢,
Joerg.约尔格。
In MainActivity.cs:在 MainActivity.cs 中:
using Android.Views;
...
public class MainActivity : MauiAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
this.Window.DecorView.SystemUiVisibility = (StatusBarVisibility)
(SystemUiFlags.ImmersiveSticky | SystemUiFlags.HideNavigation |
SystemUiFlags.Fullscreen | SystemUiFlags.Immersive);
}
}
I don't know which of those flags are needed, so I set them all.我不知道需要哪些标志,所以我将它们全部设置。
Tested on a newer device.在较新的设备上测试。 But should work fine on an API-25 device.
但在 API-25 设备上应该可以正常工作。
SystemUiVisibility
is marked as deprecated, but it still works. SystemUiVisibility
被标记为已弃用,但它仍然有效。
If you set targetSdkVersion to API-31, you could add if-test to use WindowInsetsController where available.如果将 targetSdkVersion 设置为 API-31,则可以添加 if-test 以在可用的情况下使用 WindowInsetsController。 (Though it sounds like you have a specific device to run on, so not relevant to your situation.)
(虽然听起来你有一个特定的设备可以运行,所以与你的情况无关。)
NOTE: targetSdkVersion and TargetFrameworkVersion do not have to be API-25;注意:targetSdkVersion 和 TargetFrameworkVersion 不必是 API-25; its fine if they are newer.
如果它们是新的,那很好。 Not sure how Maui is setting TargetFrameworkVersion.
不确定 Maui 如何设置 TargetFrameworkVersion。 I think
net6.0-android
is defaulting to API-31.我认为
net6.0-android
默认为 API-31。 Causing the warning you see.导致您看到的警告。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.