且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

fitSystemWindows到底能做什么?

更新时间:2023-02-24 12:34:22

系统窗口是系统绘制屏幕的部分 非交互式(对于状态栏)或交互式 (对于导航栏)内容.

System windows are the parts of the screen where the system is drawing either non-interactive (in the case of the status bar) or interactive (in the case of the navigation bar) content.

在大多数情况下,您的应用无需在状态栏或 导航栏,但如果要这样做:您需要确保交互式 元素(如按钮)并未隐藏在其下方.那就是 android:fitsSystemWindows ="true"属性的默认行为 给您:它设置视图的填充以确保内容 不要覆盖系统窗口.

Most of the time, your app won’t need to draw under the status bar or the navigation bar, but if you do: you need to make sure interactive elements (like buttons) aren’t hidden underneath them. That’s what the default behavior of the android:fitsSystemWindows="true" attribute gives you: it sets the padding of the View to ensure the contents don’t overlay the system windows.

https://medium.com/google-开发人员/为什么我要适应systemwindows-4e26d9ce1eec