如何在CollapsingToolbarLayout中滚动Recyclerview

编程入门 行业动态 更新时间:2024-10-19 04:27:55
本文介绍了如何在CollapsingToolbarLayout中滚动Recyclerview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在CollapsingToolbarLayout中有recyclerview,我希望它可以滚动,但不是.当我滚动时,appbar正在滚动,但不是recyclerview.我尝试了不同的方法,但是没有用.这是我的代码:

I have recyclerview inside CollapsingToolbarLayout and I want it to be scrollable, but it is not. When I scroll, appbar is scrolling but not recyclerview. I tried different things, but it doesn't work. Here's my code:

<android.support.design.widget.CoordinatorLayout xmlns:android="schemas.android/apk/res/android" xmlns:app="schemas.android/apk/res-auto" android:id="@+id/caves_content" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <android.support.design.widget.AppBarLayout android:id="@+id/appBar" android:layout_width="match_parent" android:layout_height="@dimen/app_bar_height" android:theme="@style/AppTheme.AppBarOverlay" android:fitsSystemWindows="true"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapse" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" app:layout_scrollFlags="scroll" android:nestedScrollingEnabled="true" app:titleEnabled="false"> <ImageView android:id="@+id/caves_backdrop" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" android:background="@mipmap/mount" android:adjustViewBounds="true" android:scaleType="centerCrop" /> <android.support.v7.widget.RecyclerView android:id="@+id/recycler" android:layout_width="match_parent" android:layout_height="200dp"/> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" app:theme="@style/WhiteToolbarStyle" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:layout_collapseMode="none" /> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> <android.support.v4.widget.NestedScrollView android:id="@+id/nested" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <include layout="@layout/content"/> </android.support.v4.widget.NestedScrollView> </android.support.design.widget.CoordinatorLayout>

推荐答案

我找到了解决方案:

recyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() { @Override public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { int action = e.getAction(); switch (action) { case MotionEvent.ACTION_MOVE: rv.getParent().requestDisallowInterceptTouchEvent(true); break; } return false; } @Override public void onTouchEvent(RecyclerView rv, MotionEvent e) { } @Override public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { } });

更多推荐

如何在CollapsingToolbarLayout中滚动Recyclerview

本文发布于:2023-10-08 01:30:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471117.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   CollapsingToolbarLayout   Recyclerview

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!