fitsSystemWindows的作用

本文解释了Android中布尔型属性fitsSystemWindows的作用,它如何影响视图布局以适应系统窗口如状态栏。了解其在Activity和Fragment中的行为,并通过示例展示了开启和关闭该属性时的不同效果。
摘要由CSDN通过智能技术生成

布尔型内部属性,根据系统窗口(如状态栏)调整视图布局。如果为true,则调整此视图的填充,使系统窗口留出空间可以显示状态栏及导航栏。仅当此视图处于非嵌入式活动时才生效,即使在Acitivity的根布局才有效,在Fragment中的根布局设置是无效的。

<!-- Boolean internal attribute to adjust view layout based on system windows such as the status bar.If true, adjusts the padding of this view to leave space for the system windows.Will only take effect if this view is in a non-embedded activity. -->
<attr name="fitsSystemWindows" format="boolean" />

示例Activity布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"       
    android:fitsSystemWindows="true"
    android:orientation="vertical">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="240dp"
        android:scaleType="centerCrop"
        android:src="@drawable/lufei"/>
	...
</LinearLayout>

android:fitsSystemWindows="false"

android:fitsSystemWindows="true"

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值