汉堡包切换图标显示不正确。

时间:2017-06-05 16:40:00

标签: android android-layout android-studio hamburger-menu

我正在尝试开发一款具有ActionBarDrawerToggle汉堡包图标的Android应用程序。一切正常,但汉堡包图标显示不正确。如图所示,它从顶部剪下来。我试图调整工具栏的高度,但没有用。亲切的建议,我的布局文件有问题吗?下面是我的主要活动文件和图像文件

<android.support.v4.widget.DrawerLayout

    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:openDrawer="start"
    tools:context="com.example.xxx.zzz.MainActivity">


    <!--<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">


    </LinearLayout>-->
    <android.support.design.widget.NavigationView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/navView"
        app:menu="@menu/drawer_menu"
        app:headerLayout="@layout/header_layout"
        android:layout_gravity="start"
        >

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


<android.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:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    android:fitsSystemWindows="true"
    >


    <android.support.v7.widget.Toolbar
        android:id="@+id/mtoolbar"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:background="@color/colorPrimary"
        android:layout_height="60dp"
        app:layout_collapseMode="pin"
        android:elevation="5dp"
        android:minHeight="?attr/actionBarSize"
        app:theme="?actionBarTheme"
        />

    <!-- android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" -->
    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/detail_backdrop_height"
        android:background="?attr/colorPrimary"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        >


        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:titleEnabled="false"
            app:expandedTitleTextAppearance="@android:color/transparent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">



                <ImageView
                    android:id="@+id/backdrop"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:scaleType="centerCrop"
                    android:src="@drawable/tea2"
                    app:layout_collapseMode="parallax"
                    app:layout_collapseParallaxMultiplier="0.7"
                    />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:gravity="center_horizontal"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/text_view_products"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Our Products"
                        android:textColor="@android:color/black"
                        android:textSize="@dimen/backdrop_title" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Buy online!"
                        android:textStyle="italic"
                        android:textColor="@android:color/black"
                        android:textSize="@dimen/backdrop_subtitle" />

                </LinearLayout>
            </RelativeLayout>



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


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



    <include layout="@layout/card_view" />





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


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

enter image description here

1 个答案:

答案 0 :(得分:0)

我犯了一个小错误。我需要将导航视图部分放在协调器布局部分之后。在这样做它工作正常。修改后的代码如下:

&#13;
&#13;
GameStarted
&#13;
&#13;
&#13;