Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.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 不想展开折叠工具栏_Android - Fatal编程技术网

Android 不想展开折叠工具栏

Android 不想展开折叠工具栏,android,Android,我正在使用一个折叠工具栏。如果我启动一个特定的片段,我想折叠工具栏,这样它的行为就像一个“正常”的,用户不能自己展开它。此外,当我折叠时,我只希望滚动视图,而不希望滚动工具栏。以下是我用于工具栏的布局: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/a

我正在使用一个折叠工具栏。如果我启动一个特定的片段,我想折叠工具栏,这样它的行为就像一个“正常”的,用户不能自己展开它。此外,当我折叠时,我只希望滚动视图,而不希望滚动工具栏。以下是我用于工具栏的布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/collapsing_height"
        android:fillViewport="true"
        android:fitsSystemWindows="true"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <RelativeLayout
            android:id="@+id/past_upcoming_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#efeded"
            android:fitsSystemWindows="true"
            android:orientation="vertical"
            app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">

            <TextView
                android:id="@+id/upcoming_heading"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:gravity="center_horizontal"
                android:padding="@dimen/spacing_normal_8dp"
                android:text="@string/upcoming_appointments"
                android:textSize="@dimen/text_size18sp" />

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/upcoming_heading">

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/upcoming_appointments_recycler_view"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:layout_marginTop="10dp"
                    android:orientation="horizontal" />

                <TextView
                    android:id="@+id/no_upcoming_list"
                    android:layout_width="wrap_content"
                    android:layout_height="200dp"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:text="@string/no_upcoming_appointment"
                    android:textSize="@dimen/text_size18sp" />
            </FrameLayout>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:layout_alignParentBottom="true"
                android:layout_gravity="center"
                android:gravity="center"
                android:text="@string/past_appointments"
                android:textSize="@dimen/text_size18sp" />

        </RelativeLayout>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            app:layout_scrollFlags="scroll|enterAlways">

        </android.support.v7.widget.Toolbar>


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


<android.support.v4.widget.NestedScrollView
    android:id="@+id/nestedscrollview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#efeded"
        android:orientation="vertical">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/past_appointments_recycle_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" />
    </LinearLayout>
</android.support.v4.widget.NestedScrollView>
这不会将工具栏粘贴到顶部。它使用嵌套的滚动视图向上滚动。请帮忙。 提前谢谢

CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams();
        lp.height = (int) getResources().getDimension(R.dimen.collapsing_height);