Android getStableInsetTop()是否始终返回0?

Android getStableInsetTop()是否始终返回0?,android,android-layout,windowinsets,Android,Android Layout,Windowinsets,我想得到稳定的系统用户界面插图。从中获取系统UI(导航栏和状态栏)的高度和宽度 问题:我使用了windowInsets类的getSystemWindowInsetTop()方法,但当屏幕进入沉浸式模式且系统UI(导航栏和状态栏)隐藏时,它将变为零。但是我需要稳定的插入,这就是为什么我尝试使用getStableinsetop()方法,它总是返回0 代码: binding.lytParent.setOnApplyWindowInsetsListener((view, windowInsets) -&

我想得到稳定的系统用户界面插图。从中获取系统UI(导航栏和状态栏)的高度和宽度

问题:我使用了windowInsets类的
getSystemWindowInsetTop()
方法,但当屏幕进入沉浸式模式且系统UI(导航栏和状态栏)隐藏时,它将变为零。但是我需要稳定的插入,这就是为什么我尝试使用
getStableinsetop()
方法,它总是返回0

代码:

binding.lytParent.setOnApplyWindowInsetsListener((view, windowInsets) -> {
                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                        ViewGroup.LayoutParams.MATCH_PARENT
                        , windowInsets.getStableInsetTop()
                );
                binding.vTopMargin.setLayoutParams(params);
});
注意:我已经在我的XML父布局中添加了
fitSystemWindows=“true”
属性
getSystemWindowInsetTop()
工作正常并返回插入值,但问题是它的值随系统UI(导航栏和状态栏)的可见性而变化