关于fitsSystemWindow

  • 1.fitsSystemWindow 默认是true,就是组件都在屏幕内,但是不包括statusBar。设置成false后,整个屏幕都可以放置组件,没有statusBar和window之分。

  • 2.android:fitsSystemWindows=“true”在布局中占有最高权限,如果明确设置为true,style设置fits为false是无效的;同理,只在布局中设置fits而没有设置style也是无效的。

平时使用中只需要设置style即可。效果就是整个图片铺满手机界面。

<style name="NoStatusStyle" parent="AppTheme">    
<item name="android:windowTranslucentStatus">true</item>    <!--状态栏为透明,如果设置为false,则没有黑色条盖住,见下图对比-->
<item name="android:windowTranslucentNavigation">true</item> <!--导航栏为透明-->    
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
android:windowTranslucentStatus为true
android:windowTranslucentStatus为false

(注:在布局中都是android:fitsSystemWindows="false")

  • 3.有时候会出现statusbar把界面盖住的情况,一般都是fits设置的有问题,或是在布局(android:fitsSystemWindows="false"),或是在style中fits设置为了false(<item name="android:fitsSystemWindows">false</item>),但是statusbar没有设置为透明,造成了界面被遮盖的现象。解决办法就是上面的代码块中的代码。(要明白自己的意图再去修改)
一定是fits有问题
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容