在CollapsingToolbarLayout和NestedScrollView上滚动内容的问题

时间:2016-12-05 17:09:41

标签: android scrollview android-nestedscrollview

我在使用CollapsingToolbarLayout滚动内容框架内容时遇到问题。有没有办法让我有一个带有CollapsingToolbarLayout的可滚动内容窗格?使用NestedScrollView尝试没有运气

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        app:title="@string/app_name"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:statusBarScrim="?attr/colorPrimaryDark"
        app:expandedTitleTextAppearance="@style/AppTheme"
        app:expandedTitleMarginEnd="64dp"
        app:expandedTitleMarginStart="48dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <ImageView
            android:id="@+id/image"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            android:scaleType="centerCrop"
            android:src="@drawable/vehicle"
            app:layout_collapseMode="parallax" />

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

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

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

<android.support.v4.widget.NestedScrollView
    android:id="@+id/scroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="fill_vertical"
    android:clipToPadding="false"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" >

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/content_frame"/>

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

例外:

java.lang.RuntimeException:
Unable to start activityComponentInfo{ke.com.myapp.myapp/ke.com.myapp.myapp.activities.MainActivity}: android.view.InflateException: Binary XML file line #11: Could not inflate Behavior subclass android.support.design.widget.AppBarLay‌​‌​out$ScrollingViewB‌​eh‌​avior
                                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)

0 个答案:

没有答案