简体   繁体   English

如何在Xamarin.Form应用中获取Android底层软件Navigation Bar的高度?

[英]How can I get the height of Android bottom software Navigation Bar in Xamarin.Form app?

I'm confused that in different documents, Navigation Bar refers to different controls, but here, it is the Android feature, which provides navigation controls besides the hardware buttons. 我很困惑,在不同的文档中,导航栏指的是不同的控件,但是在这里,它是Android功能,除了硬件按钮之外,它还提供了导航控件。 I hope to get the height of this bar wide code. 我希望了解此条形码的高度。

After digging solutions about hiding the bar permanently, I reaized it's not possible to do so (which is the most desiered way of sovling the problem), please do correct me if the bar can be hide permanently!!! 在找到有关永久隐藏栏的解决方案之后,我发现不可能这样做(这是解决问题的最渴望的方法),如果栏可以永久隐藏,请纠正我!!! I attached the code here I used to hide the bar, but whenever I tap the screen, the bar re-appear. 我在这里附加了用于隐藏该栏的代码,但是每当我点击屏幕时,该栏就会重新出现。

Instead, can I get the height of the bottom software navigation bar on Android so that I can adjust the position of page elements accordingly? 而是可以获取Android底部软件导航栏的高度,以便相应地调整页面元素的位置吗? (What is more annyoing is that some Android devices allow user the manually show and hide the bar by clicking an arrow button on the bar.) (更令人遗憾的是,某些Android设备允许用户通过单击工具栏上的箭头按钮来手动显示和隐藏该工具栏。)

//In OnCreate of MainActivity.cs,

int uiOptions = (int)Window.DecorView.SystemUiVisibility;
uiOptions |= (int)SystemUiFlags.HideNavigation;
Window.DecorView.SystemUiVisibility = (StatusBarVisibility)uiOptions;

//In some topics, people said to add some more SystemUiFlags, such as IMMERSIVE_STICKY, LAYOUT_FULLSCREEN, but with those, the bar cannot be hidden.

在此处输入图片说明 Strangly, DeviceDisplay.MainDisplayInfo.Height includes the height of the Navigation bar, otherwise I don't need to do what described above. 遗憾的是,DeviceDisplay.MainDisplayInfo.Height包含导航栏的高度,否则我不需要执行上述操作。 Is there a way of detecting screen height without the software navigation bar? 没有软件导航栏,是否可以检测屏幕高度?

Thanks so much for any help on this. 非常感谢您对此提供的任何帮助。

PS: Instead of getting the height, can I at least detect if the software navigation bar is on / shown?! PS:除了获取高度以外,我是否至少可以检测软件导航栏是否打开/显示? Now I know I can detect if the device has hard navigation keys with ViewConfiguration.Get(Android.App.Application.Context).HasPermanentMenuKey, this is useful, but I still can't detect if the soft navigation bar is on or not. 现在我知道我可以使用ViewConfiguration.Get(Android.App.Application.Context).HasPermanentMenuKey来检测设备是否具有硬导航键,这很有用,但是我仍然无法检测到软导航栏是否处于打开状态。

About get Navigation bar height in xamarin.form, you can try to use: 关于在xamarin.form中获取导航栏高度,您可以尝试使用:

 TypedArray styledAttributes = this.Theme.ObtainStyledAttributes(new int[] {Android.Resource.Attribute.ActionBarSize });
        var actionbarHeight = (int)styledAttributes.GetDimension(0, 0);
        styledAttributes.Recycle();
        Console.WriteLine("the height is {0}",actionbarHeight);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Xamarin Android 中获取导航栏高度? - How to get Navigation bar Height in Xamarin Android? 如何将底部导航栏实现为Android应用程序? - How can I implement the bottom navigation bar into an app for android? 如何获得 Material Design 3 的底部导航栏高度? - How do I get the bottom navigation bar height for Material Design 3? android-如何使用底部应用栏实现导航 - android - How to implement navigation with bottom app bar 如何以编程方式获取 Android 导航栏的高度和宽度? - How do I get the height and width of the Android Navigation Bar programmatically? 如何真正获得 Android 中的导航栏高度 - How to REALLY get the navigation bar height in Android 如何在 xamarin forms 中增加导航栏的高度:Android - How to increase the height of Navigation bar in xamarin forms : Android 我可以将Android工具栏与底部导航栏一起使用吗? - Can i use android toolbar with bottom navigation bar? 我可以将快餐栏锚定到 Android 原生底部导航栏吗? - Can I anchor a snackbar to Android native bottom navigation bar? 如何在android中使用底部导航栏获取sidenav? - How to get sidenav from using bottom navigation bar in android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM