1

プロジェクトで Android サポート デザイン ライブラリを使用しています。これは、DrawerLayout、CoordinatorLayout、AppBarLayout、ToolBar、および NavigationView を含む私の layout.xml です。実際、私のアクティビティには NavigationDrawer が含まれており、FrameLayout @+id/container は FragmentManager が Fragment を追加/置換する場所です。私の問題は、このコンテナー FrameLayout の属性として app:layout_behavior を必要とする 1 つの Fragment と、それを必要としない別の Fragment があることです。最初のフラグメントがコンテナのコンテンツである場合はこの動作を有効にし、別のフラグメントの場合は無効にする必要があります。どうやってやるの ?

私の activity_main.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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.hhsociete.mybootstrap.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">
            <!-- The ActionBar -->
            <include
                layout="@layout/toolbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_scrollFlags="scroll|enterAlways"/>
        </android.support.design.widget.AppBarLayout>
        <FrameLayout
            android:id="@+id/container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

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

    <!-- The navigation drawer -->
    <android.support.design.widget.NavigationView
        android:id="@+id/nvView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@android:color/white"
        app:menu="@menu/drawer_view"
        app:headerLayout="@layout/nav_header"/>

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

0 に答える 0