首页 > 解决方案 > app如何获取导航栏的模式

问题描述

意思是,应用程序如何在以下3种模式中获得导航栏模式

标签: android

解决方案


您可以使用以下代码,可能不适用于所有 android 设备

public static int isEdgeToEdgeEnabled(Context context) {
        Resources resources = context.getResources();
        int resourceId = resources.getIdentifier("config_navBarInteractionMode", "integer", "android");
        if (resourceId > 0) {
            return resources.getInteger(resourceId);
        }
        return 0;
    }

isEdgeToEdgeEnabled 函数返回的值如下:

  • 导航显示有 3 个按钮

  • 使用 2 个按钮显示导航(Android P 导航模式)

  • 全屏手势(Android Q上的手势)


推荐阅读