我很困惑,在不同的文档中,导航栏指的是不同的控件,但是在这里,它是Android功能,除了硬件按钮之外,它还提供了导航控件。
我希望了解此条形码的高度。
在找到有关永久隐藏栏的解决方案之后,我发现不可能这样做(这是解决问题的最渴望的方法),如果栏可以永久隐藏,请纠正我!!!我在这里附加了用于隐藏该栏的代码,但是每当我点击屏幕时,该栏就会重新出现。
而是可以获取Android底部软件导航栏的高度,以便相应地调整页面元素的位置吗?
(更令人遗憾的是,某些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.
非常感谢您对此提供的任何帮助。
PS:除了获取高度以外,我是否至少可以检测软件导航栏是否打开/显示?
现在我知道我可以使用ViewConfiguration.Get(Android.App.Application.Context).HasPermanentMenuKey来检测设备是否具有硬导航键,这很有用,但是我仍然无法检测到软导航栏是否打开。
最佳答案
关于在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);