我有一个包含FrameLayout的AppBarLayout,它包含一个ImageView。 FrameLayout本身位于CollapsingToolbarLayout中。 在AppBarLayout的底部,有一个RecyclerView。
代码如下
<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/root"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="ifContentScrolls">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/img_video_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
>
<ImageView
android:id="@+id/cropper_view"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="#ff282828"
android:visibility="visible"/>
</FrameLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/img_video_view"/>
当用户触摸AppbarLayout部分时,我不想滚动发生。我想在用户触摸Recyclerview时进行向上滚动。 我怎么能这样做?
提前致谢。
答案 0 :(得分:0)
我解决了我的问题。 :-) 根据我的问题,我想将AppBarLayout的触摸事件传递给它内部的ImageView。我覆盖了AppBarLayout的onInterceptTouchEvent,CollapsingToolbarLayout和FrameLayout,如下所示并返回false;
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return false;
}
通过这种方式,没有任何一个父视图捕获触摸事件,触摸事件将传递给ImageView。