Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 当系统和导航栏被隐藏时,如何获取它们的真实高度_Java_Android - Fatal编程技术网

Java 当系统和导航栏被隐藏时,如何获取它们的真实高度

Java 当系统和导航栏被隐藏时,如何获取它们的真实高度,java,android,Java,Android,我希望在Android设备上,当导航条被隐藏时,可以通过root获取它们的真实(!)状态或高度(系统和导航) 超级用户命令隐藏的条: 我尝试通过以下方式获取系统和导航栏的高度: 但是这个方法返回虚拟高度:我的设备上的状态栏-38px,导航栏-72px 我需要得到这个尺寸只有当酒吧真正显示在屏幕上。在带有隐藏条的情况下返回0 有可能达到真正的高度吗 也可能得到状态系统和导航栏:隐藏还是显示 // status bar (at the top of the screen on a Nexus dev

我希望在Android设备上,当导航条被隐藏时,可以通过root获取它们的真实(!)状态或高度(系统和导航)

超级用户命令隐藏的条:

我尝试通过以下方式获取系统和导航栏的高度:

但是这个方法返回虚拟高度:我的设备上的状态栏-38px,导航栏-72px

我需要得到这个尺寸只有当酒吧真正显示在屏幕上。在带有隐藏条的情况下返回0

有可能达到真正的高度吗

也可能得到状态系统和导航栏:隐藏还是显示

// status bar (at the top of the screen on a Nexus device) 
public static int getStatusBarHeight(Context context) {
    Resources resources = context.getResources();
    int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }
    return 0;
}

// navigation bar (at the bottom of the screen on a Nexus device)
public static int getNavigationBarHeight(Context context) {
    Resources resources = context.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }
    return 0;
}