niorgai / StatusBarCompat

Status Bar Utils ---- Change Status Bar Mode Simply

Home Page:http://niorgai.github.io/2016/03/20/Android-transulcent-status-bar/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DrawerLayout上面多了一条空白

YiuChoi opened this issue · comments

commented

你好 可以看一下你的布局吗?还有手机型号和系统版本,我这边试不出来

确实有这种现象存在

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/main_bg"
    tools:context=".activity.MainActivity">



    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|enterAlways"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:navigationIcon="?attr/homeAsUpIndicator"
                />
        </android.support.design.widget.AppBarLayout>


        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:background="#f2f2f2"
            />


        <android.support.design.widget.FloatingActionButton

            android:id="@+id/fabBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:layout_marginBottom="@dimen/fab_margin_bottom"
            android:layout_marginRight="@dimen/fab_margin_right"
            android:src="@drawable/ic_plus"
            app:borderWidth="0dp"
            app:fabSize="normal"
            app:layout_behavior="com.bryan.studycodes.widget.ScrollAwareFABBehavior"
            />
    </android.support.design.widget.CoordinatorLayout>


    <android.support.design.widget.NavigationView
        android:id="@+id/navigation"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:tag="LEFT"
        app:headerLayout="@layout/nav_header"
        app:menu="@menu/navigation_drawer_items" />


</android.support.v4.widget.DrawerLayout>

<!--  @layout/nav_header-->
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="@dimen/nav_header_height"
    >

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/nav_header_bg"
        android:scaleType="centerCrop" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/nuuneoi"
        android:layout_gravity="bottom"
        android:layout_marginBottom="36dp" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:layout_margin="@dimen/nav_header_text_margin_left"
        android:text="nuuneoi"
        android:textColor="@android:color/white"
        />

</FrameLayout>

在DrawerLayout 情况下,就会有一段空白

在4.4才会出现,5.0不会

commented

@cxbiao 谢谢你的说明, 是因为 NavigationView 默认设置了 fitsSystemWindows , 你可以设置 NavigationViewfitsSystemWindows 属性为false. 这个我也要补充一下