简体   繁体   English

隐藏 3 个底部按钮(返回/主页/最近)(Android 全屏)

[英]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:我努力了:

  • NavigationPage.HasNavigationBar="False" in the NavigationPage.HasNavigationBar="False" 在
  • NavigationPage.HasNavigationBar="False" in the NavigationPage.HasNavigationBar="False" 在
  • NavigationPage.HasNavigationBar="False" in the NavigationPage.HasNavigationBar="False" 在

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:我发现的隐藏导航按钮的示例都因各种原因而因语法错误而失败:

  • DecorView doesn't have the SetSystemUiVisibility method DecorView 没有 SetSystemUiVisibility 方法
  • Android.Views.WindowManagerFlags doesn't have all the flags, such as "immersive", etc. Android.Views.WindowManagerFlags 没有所有的标志,例如“沉浸式”等。
  • WindowInsetsController is not available in API version 25 WindowInsetsController 在 API 版本 25 中不可用

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.

相关问题 如何永久禁用Android中的底部导航按钮(返回,首页,最新应用/菜单)? - How to disable bottom navigation buttons(Back,Home,recent apps/menu) in android permanently? 隐藏按钮返回、主页、Android 应用程序 - Hide Buttons Back, Home, Android Applications Android 仿真器控制按钮(返回、主页、最近)不起作用 - Android emulator control buttons (back, home, recent) are not working 如何以 xamarin 形式隐藏 android(返回,主页)的底部栏? - how to hide bottom bar of android (back, home) in xamarin forms? 如何禁用 flutter 中的后退、主页和最近按钮? - How to disable back, home and recent buttons in flutter? 禁用/不执行任何操作(返回,最近和主页按钮)! - disable/do nothing ( back , recent ,and home buttons)! Android-如何关闭Google Pixel 2上的首页/后退/最新应用程序按钮指示灯 - Android - How to turn off home/back/recent apps buttons light on Google Pixel 2 在Android中禁用主页和后退按钮 - Disable home and back buttons in android 以编程方式隐藏 Android 应用程序中的主页和最近按钮 - Hide Home and Recent Button in Android App Programatically 以编程方式在Android中禁用“返回”,“首页”和“最近”按钮 - Disable back, Home and Recent button in android programmatically
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM