<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/detail_backdrop_height"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll"
app:layout_collapseMode="parallax" />
...
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.v4.widget.nestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
....
请注意,我已经添加了添加android:fillViewport =“true”到nestedScrollView并添加了app:layout_scrollFlags =“scroll”to
ImageView但是当试图从ImageView滚动时没有任何反应.
解决方法
Check out the bug report here
摘抄
I have taken a look at the implementation that backs
CoordinatorLayout/AppBarLayout/theBehaviorclasses etc. TheAppBarLayoutuses the behavIoUr defined inAppBarLayout.Behaviorby default. This extendsViewOffsetBehaviorwhich in turn extendsBehavior. The baseBehaviorclass has the methodsonInterceptTouchEvent()andonTouchEvent(),both of which return false (meaning “we don’t want to handle touch events”). These methods are not overridden by eitherViewOffsetBehaviororAppBarLayout.Behavior,meaning that the touch is left unhandled – which is why it does nothing.A possible workaround for third-party developers would be to extend
AppBarLayout.Behaviorand implementonInterceptTouchEvent()andonTouchEvent()and manipulate the app bar accordingly.
影片
这些显示了当前和预期的行为.这些也来自错误报告.
> https://youtu.be/xWadOVEaTSY
> https://youtu.be/J8ITp6RusZo