Android appcompt库23.1.1:CollapsingToolbarLayout在滚动时不会折叠

时间:2015-12-19 14:43:30

标签: android android-support-library android-support-design android-collapsingtoolbarlayout

如果我使用" com.android.support:design:23.0.1 "此代码非常有用。但如果我用新版本更新了Grade1" com.android.support:design:23.1.1 "就像一切都冻结了

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/root_coordinator"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/app_bar_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            >
            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/collapsing_toolbar_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                app:expandedTitleMarginEnd="64dp"
                app:expandedTitleMarginStart="48dp"
                app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">

                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="192dp"
                    android:scaleType="centerCrop"
                    android:src="@drawable/header"
                    app:layout_collapseMode="parallax" />


                <LinearLayout
                    android:id="@+id/title"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    app:layout_collapseMode="parallax"
                    android:orientation="vertical">
                    <TextView
                        android:id="@+id/name"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center_horizontal"
                        android:layout_marginTop="15dp"
                        android:padding="10dp"
                        tools:text="Your Name"
                        android:textColor="@android:color/white"
                        android:textSize="24sp"
                        />

                    <TextView
                        android:id="@+id/period"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center_horizontal"
                        android:padding="10dp"
                        tools:text="Period"
                        android:textColor="@android:color/white"
                        android:textSize="18sp"    
                        />

                    <TextView
                        android:id="@+id/year"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:gravity="center_horizontal"
                        tools:text="2015"
                        android:textColor="@android:color/white"
                        android:textSize="18sp"    
                        />
                </LinearLayout>


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

        <android.support.v7.widget.RecyclerView
            android:id="@+id/list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            />
</android.support.design.widget.CoordinatorLayout>

问题

  • 我无法崩溃
  • 我无法滚动RecyclerView

如果我发表评论&#34; CollapsingToolbarLayout &#34; RecyclerView滚动没有问题

1 个答案:

答案 0 :(得分:0)

app:layout_scrollFlags="scroll|exitUntilCollapsed"

在CollapsingToolbarLayout中使用它,看看它是否正常工作。