属性介绍

android 布局xml中 android:fitsSystemWindows=”true”的原文解析为:

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.

内置的一个布尔值属性,通过其去调整基于系统窗口的视图布局,例如状态栏,如果该值为真,调整这个视图的内边距与系统窗口的距离,只有该view是non-embedded(非嵌入的)的activity才会产生影响。

即在开放过程中设计应用程序布局时当考虑当系统窗口的影响时,设置该值,如果为true,将自动调整系统窗口布局来适应你自定义的布局。例如:当系统有状态栏,你的应用也存在状态栏时便可以设置为ture。
(转自https://my.oschina.net/zaizaiangels/blog/634267?p=1)

自己挖的坑

在下面的布局文件中,AppBarLayout和Toolbar里面使用了 android:fitsSystemWindows=”true”的属性,导致了下面图片中状态把顶部菜单栏遮挡住了,去掉后问题这两个地方的属性,解决了,折腾了1个小时终于搞定了。

<?xml version="1.0" encoding="utf-8"?>.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:fitsSystemWindows="true"    tools:context=".ui.common.MainActivity">    .support.design.widget.AppBarLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:fitsSystemWindows="true"        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">        .support.v7.widget.Toolbar            android:id="@+id/toobar_widget"            android:layout_width="match_parent"            android:layout_height="@dimen/toolbar_height"            android:fitsSystemWindows="true"            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"            app:theme="@style/Theme.AppCompat.Light">            "@+id/toobar_txt_title"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:layout_centerInParent="true"                android:text="@string/menu_home"                android:textColor="@color/txt_h5"                android:textSize="@dimen/txt_19sp" />            "24dp"                android:layout_height="24dp"                android:layout_gravity="right"                android:layout_marginRight="@dimen/margin_long"                android:src="@drawable/ic_menu_search" />        .support.v7.widget.Toolbar>    .support.design.widget.AppBarLayout>    "@+id/llayout_context"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:background="@color/bg_content_area"        app:layout_behavior="@string/appbar_scrolling_view_behavior" />    <com.ashokvarma.bottomnavigation.BottomNavigationBar        android:id="@+id/navbar"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_gravity="bottom" />.support.design.widget.CoordinatorLayout>

更多相关文章

  1. TextView 设置 Ellipsize 属性,但它不工作?
  2. Configuration on demand is not supported by the current vers
  3. android 界面属性
  4. Android中对话框的使用
  5. android登录简单窗口
  6. android Animation介绍
  7. 屏蔽EditText自动获取焦点
  8. style和theme小用法
  9. Android滚动文字效果

随机推荐

  1. Android访问WCF服务
  2. android 电量
  3. Android(安卓)读写文件的N种写法
  4. 原文:Android(安卓)Theme XML
  5. 聊聊 Android(安卓)的网络请求框架 Retro
  6. 错误:Gradle sync failed: Could not find
  7. android 界面跳转
  8. 为usb网卡设置ip地址之一
  9. android window的requestWindowFeature()
  10. android锁屏页面的实现