[英]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.