Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何禁用或启用默认添加在layout.xml中的programmaticaly layout_行为_Android_Xml_Android Fragments_Android Support Design - Fatal编程技术网

Android 如何禁用或启用默认添加在layout.xml中的programmaticaly layout_行为

Android 如何禁用或启用默认添加在layout.xml中的programmaticaly layout_行为,android,xml,android-fragments,android-support-design,Android,Xml,Android Fragments,Android Support Design,我正在我的项目中使用android支持设计库。这是我的layout.xml,包括抽屉布局、坐标布局、AppBarLayout、工具栏和导航视图。事实上,我的活动包含一个NavigationDrawer,FrameLayout@+id/容器是FragmentManager添加/替换片段的地方。我的问题是,我有一个片段需要app:layout\u behavior作为这个容器FrameLayout的属性,还有一个片段不需要它。我需要在第一个片段是容器的内容时启用此行为,并在另一个片段的情况下禁用它。

我正在我的项目中使用android支持设计库。这是我的layout.xml,包括抽屉布局、坐标布局、AppBarLayout、工具栏和导航视图。事实上,我的活动包含一个NavigationDrawer,FrameLayout@+id/容器是FragmentManager添加/替换片段的地方。我的问题是,我有一个片段需要app:layout\u behavior作为这个容器FrameLayout的属性,还有一个片段不需要它。我需要在第一个片段是容器的内容时启用此行为,并在另一个片段的情况下禁用它。我该怎么做

My 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>