派遣后有没有办法获得现有的窗口插件?

Tom*_*Tom 13 android

有没有办法WindowInsets在活动创建之后很长时间内获取活动,而无需坚持或以其他方式缓存它?

例如.

WindowInsets insets = getWindow().getWindowInsets();
myUseCaseView.setPaddingTop(insets.getSystemWindowInsetTop);
Run Code Online (Sandbox Code Playgroud)

rds*_*rds 9

是的: getWindow().getDecorView().getRootWindowInsets()

  • 支持库允许您通过执行 `ViewCompat.getRootWindowInsets(getWindow().getDecorView())` 来返回 api >= 21。有关更多详细信息,请参阅 ViewCompat.getRootWindowInsets(View)](https://developer.android.com/reference/androidx/core/view/ViewCompat#getRootWindowInsets(android.view.View))。 (5认同)
  • 我对状态栏、导航按钮等更感兴趣,目的是在它们后面绘制,同时插入内容,使其不会被系统栏遮挡 (4认同)
  • 有 <23 的替代方案吗? (2认同)
  • 不,我猜 23 年前的手机都没有刘海。 (2认同)