判断activity是否开启沉浸式状态栏

public boolean isImmersiveStatusBar(Activity activity) {
        ViewGroup viewGroup = activity.getWindow().getDecorView().findViewById(android.R.id.content);
        int[] location = new int[2];
        viewGroup.getLocationInWindow(location);
        if (location[1] == 0) {
            return true;
        } else {
            return false;
        }
    }

可以借助android studio的工具栏中的Tools->LayoutInspector查看当前界面的布局和约束情况

你可能感兴趣的:(android)