Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.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
Android P的Android导航栏可视性-检测基于手势的导航_Android_Navigation_Android 9.0 Pie - Fatal编程技术网

Android P的Android导航栏可视性-检测基于手势的导航

Android P的Android导航栏可视性-检测基于手势的导航,android,navigation,android-9.0-pie,Android,Navigation,Android 9.0 Pie,如何检测导航栏(用于无Bazel设备)是否可见?我尝试了使用资源标识符、系统UI标志和KeyCharacterMap的不同导航栏解决方案,但它对我不起作用。在和ID P中,可以使用手势导航,这将隐藏导航栏,导航功能将使用该手势运行。有什么解决方案可以检测到这一点吗?我使用双手势导航方法在小米设备上测试了这段代码,对我来说,它工作正常: Point p = new Point(); getWindow().getWindowManager().getDefaultDisplay()

如何检测导航栏(用于无Bazel设备)是否可见?我尝试了使用资源标识符系统UI标志KeyCharacterMap的不同导航栏解决方案,但它对我不起作用。在和ID P中,可以使用手势导航,这将隐藏导航栏,导航功能将使用该手势运行。有什么解决方案可以检测到这一点吗?

我使用双手势导航方法在小米设备上测试了这段代码,对我来说,它工作正常:

Point p = new Point();
        getWindow().getWindowManager().getDefaultDisplay().getRealSize(p);
        ConstraintLayout container = findViewById(your activity main view (e.g linearLayout));

        final TypedArray styledAttributes = getTheme().obtainStyledAttributes(
                new int[]{android.R.attr.actionBarSize});
        int mActionBarSize = (int) styledAttributes.getDimension(0, 0);
        int height = container.getMeasuredHeight();
        int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
        int result = 0;
        if (resourceId > 0) {
            result = getResources().getDimensionPixelSize(resourceId);
        }
if (height + mActionBarSize + result >= p.y) {
     //you have fullscreen gesture navigation
}else{
     //navigation bar or similiar
}
这是因为该应用程序现在可以在屏幕上显示更大的尺寸,因此只有在手势导航方法不使“导航栏”成为背景时,它才能工作


只要确保在main已加载且可见时使用它,否则它将返回0。

它对我不起作用。如果我在postDelayed中使用上述代码,它总是返回else块。如果我不使用postDelayed,它总是返回If block。@在显示视图后,您是否执行了代码?不幸的是,您无法在onCreate中完成此操作,但至少在几秒钟之后