在从backstack片段中恢复时,折叠工具栏不会完全折叠

时间:2017-03-09 12:14:39

标签: android android-fragments android-toolbar fragment-backstack

当我从后台堆栈恢复片段(包含折叠工具栏)时,折叠工具栏会卡在中间位置。它最初完全崩溃,但是当我将片段放回到堆栈中时,移动到下一个片段然后返回到这个片段然后它被卡在中途

XML

<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:minHeight="0dp"
        app:elevation="0dp">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:minHeight="200dp"
                android:transitionName="frame_layout"
                app:layout_collapseMode="parallax"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <TextView
                    android:id="@+id/tiffin_service_initials_text_view"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="40dp"
                    android:background="@color/colorPrimary"
                    android:fontFamily="sans-serif-light"
                    android:gravity="center"
                    android:text="AB"
                    android:textColor="@color/md_white_1000"
                    android:textSize="40sp"
                    android:transitionName="text_view" />
            </FrameLayout>

            <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"
                app:titleTextColor="@color/md_white_1000" />

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

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

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

        <LinearLayout
            android:id="@+id/linear_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                app:cardCornerRadius="0dp"
                app:cardElevation="2dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="horizontal">

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:clickable="true"
                        android:foreground="?selectableItemBackground"
                        android:gravity="center"
                        android:orientation="horizontal"
                        android:padding="16dp">

                        <ImageView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:src="@drawable/ic_star" />

                        <TextView
                            android:id="@+id/rating_text_view"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="8dp"
                            android:text="4.7"
                            android:textSize="20sp" />

                    </LinearLayout>

                    <View
                        android:layout_width="0.2dp"
                        android:layout_height="match_parent"
                        android:alpha="0.5"
                        android:background="@android:color/darker_gray" />

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:clickable="true"
                        android:foreground="?selectableItemBackground"
                        android:gravity="center"
                        android:orientation="horizontal"
                        android:padding="16dp">

                        <ImageView
                            android:layout_width="28dp"
                            android:layout_height="28dp"
                            android:scaleType="centerCrop"
                            android:src="@drawable/ic_call"
                            android:tint="@color/colorAccent" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="8dp"
                            android:text="@string/call"

                            android:textSize="20sp" />

                    </LinearLayout>


                    <View
                        android:layout_width="0.2dp"
                        android:layout_height="match_parent"
                        android:alpha="0.5"
                        android:background="@android:color/darker_gray" />

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:clickable="true"
                        android:foreground="?selectableItemBackground"
                        android:gravity="center"
                        android:orientation="horizontal"
                        android:padding="16dp">

                        <ImageView
                            android:layout_width="24dp"
                            android:layout_height="24dp"
                            android:scaleType="centerCrop"
                            android:src="@drawable/ic_chat"
                            android:tint="@color/md_blue_500" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="8dp"
                            android:text="Chat"

                            android:textSize="20sp" />

                    </LinearLayout>

                </LinearLayout>

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

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                android:layout_marginTop="8dp"
                app:cardCornerRadius="0dp"
                app:cardElevation="2dp">

                <LinearLayout
                    android:id="@+id/menu_linear_layout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center_vertical"
                    android:orientation="vertical"
                    android:padding="16dp">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:alpha="0.5"
                        android:text="@string/menu"
                        android:textSize="20sp" />

                    <ProgressBar
                        android:id="@+id/progress_bar"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginTop="16dp" />

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/menu_recycler_view"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="16dp"
                        android:visibility="gone">

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

                </LinearLayout>

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

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                android:layout_marginTop="8dp"
                app:cardCornerRadius="0dp"
                app:cardElevation="2dp">

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

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="16dp"
                        android:layout_marginLeft="16dp"
                        android:layout_marginTop="16dp"
                        android:alpha="0.5"
                        android:text="@string/address"
                        android:textSize="20sp" />

                    <com.google.android.gms.maps.MapView
                        android:id="@+id/map_view"
                        android:layout_width="match_parent"
                        android:layout_height="200dp">

                    </com.google.android.gms.maps.MapView>

                    <TextView
                        android:id="@+id/address_text_view"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="16dp"
                        android:textSize="12sp" />

                </LinearLayout>

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

        </LinearLayout>

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

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

0 个答案:

没有答案