工具栏的高度太小

时间:2016-02-09 22:09:42

标签: android android-toolbar

为什么工具栏开始时的高度如此之小?但是如果用户向下滚动,那么它就像第二个屏幕截图一样。
Screenshot on start Screenshot of expanded Toolbar
正如您在屏幕截图中看到的那样,它也有不正确的顶部填充。 这是我MainActivity的布局xml:

<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

1 个答案:

答案 0 :(得分:4)

所以我认为问题出在android:layout_height =&#34;?attr / actionBarSize&#34;

将其更改为android:layout_height =&#34; match_parent&#34;

并且看看发生了什么!

相关问题