工具栏的高度太小

Toolbar has too small height

为什么工具栏开始时的高度这么小?但是,如果用户向下滚动,则它看起来像第二张屏幕截图。

正如您在屏幕截图中看到的,它的顶部填充也不正确。 这是我的布局 xml of MainActivity:

<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:layout_height="match_parent"
    android:layout_width="match_parent"
    android:fitsSystemWindows="true" >

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

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:fitsSystemWindows="true"
            android:theme="@style/Theme.Paper.AppBarOverlay">

            <android.support.v7.widget.Toolbar
                android:fitsSystemWindows="true"
                app:layout_scrollFlags="scroll|enterAlways"
                android:layout_height="?attr/actionBarSize"
                android:layout_width="match_parent"
                app:popupTheme="@style/Theme.Paper.PopupOverlay">

                <include
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    layout="@layout/toolbar_spinner" />

            </android.support.v7.widget.Toolbar>

        </android.support.design.widget.AppBarLayout>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

        <android.support.design.widget.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"
            style="@style/Theme.Paper.FloatingActionButton"/>

    </android.support.design.widget.CoordinatorLayout>

    <fragment
        class="com.test.modal.NavigatorFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        tools:layout="@layout/navigator"
        android:fitsSystemWindows="true"/>

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

谁知道我做错了?在 FrameLayout 中,如果它有价值,我会膨胀 ViewPager

所以我认为问题出在 android:layout_height="?attr/actionBarSize"

改为android:layout_height="match_parent"

然后看看发生了什么!