NavigationBar 高度得到错误的值 xamarin 形式 android? [英] NavigationBar Height getting wrong value xamarin forms android?

查看:34
本文介绍了NavigationBar 高度得到错误的值 xamarin 形式 android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NavigationBar Height 获取错误值 xamarin 形式 androidpublic int GetHeight()

NavigationBar Height getting wrong value xamarin forms android public int GetHeight()

    {
        int statusBarHeight = -1;
        int resourceId = Activity.Resources.GetIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0)
        {
            statusBarHeight = Activity.Resources.GetDimensionPixelSize(resourceId);
        }
        return statusBarHeight;
    }

我认为它没有得到适当的价值如何获得正确的导航栏高度?

I thing its not getting proper value how to get proper Navigation Bar height?

推荐答案

使用 "status_bar_height" 查询状态栏的高度,即导航栏上方的部分(包含通知和系统图标,见此处).您必须使用 "navigation_bar_height"(参见此处).

With "status_bar_height" you are querying the height of the status bar, which is the part above the navigation bar (the bit containing the notification and system icons, see here). You'll have to use "navigation_bar_height" (see here).

免责声明:虽然从字面上回答您的问题,但这很可能与您想要的有所不同.Android 导航栏通常位于底部,包含 backhomeoverview 按钮(见这里).

Disclaimer: While literally answering your question, this might well be something different from what you want. The Android Navigation Bar is the bar that's usually at the bottom, containing the back, home and overview buttons (see here).

在 Android 上,您可以使用 GetBarHeight(IPlatformElementConfiguration<Android,NavigationPage>) 扩展(

On Android you have the possibility to get the height of the bar with the GetBarHeight(IPlatformElementConfiguration<Android,NavigationPage>) extension (see here), which can be used like

On<Xamarin.Forms.PlatformConfiguration.Android>.GetBarHeight()

来自导航页面背后的代码.

from the code behind of your navigation page.

这篇关于NavigationBar 高度得到错误的值 xamarin 形式 android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆