必须使用MeasureSpec.EXACTLY测量DrawerLayout,我尝试了其他解决方案但没有工作

时间:2017-12-18 11:54:18

标签: android xml navigation-drawer android-coordinatorlayout drawerlayout

我在使用底部导航添加抽屉导航时出现问题,底部导航需要coordinatorLayout,抽屉导航需要drawerLayout,所以我尝试将CoordinatorLayout嵌套在DrawerLayout中,但是我收到错误{{必须使用MeasureSpec.EXACTLY. !!

来测量DrawerLayout

有人可以为此提供帮助,因为我尝试了许多在互联网上提供的无法解决的解决方案!

<?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"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusableInTouchMode="true">

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/container"
    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">
        <include layout="@layout/activity_navigation_drawer"/>
    </android.support.design.widget.AppBarLayout>

    <ScrollView
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <TextView
            android:id="@+id/message"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/activity_vertical_margin"
            android:layout_marginLeft="@dimen/activity_horizontal_margin"
            android:layout_marginRight="@dimen/activity_horizontal_margin"
            android:layout_marginTop="@dimen/activity_vertical_margin"
            android:text="@string/title_break_news" />

    </ScrollView>

    <android.support.design.widget.BottomNavigationView
        android:layoutDirection="rtl"
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:itemIconTint="@drawable/selector"
        app:itemTextColor="@drawable/selector"
        android:background="?android:attr/windowBackground"
        app:menu="@menu/navigation" />

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

<android.support.design.widget.NavigationView

    android:id="@+id/drawerNav"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/nav_header_navigation_drawer"
    app:menu="@menu/activity_navigation_drawer_drawer"/>

0 个答案:

没有答案