NestedScrollView和RecyclerView同时存在的时候导致滑动,点击等事件问题

解决方案:在布局中NestedScrollViewRecyclerView处于平级,将RecyclerView放在在NestedScrollView的下边,效果是RecyclerView如果没有加载到数据,此时事件交给NestedScrollView处理,如果RecyclerView加载到数事件交给RecyclerView处理

这种一般是在实现悬停效果时候回出现,请求网络请求到数据列表展示,断网,无数据等等其他状态就会使用NestedScrollView,就可能出现该问题

具体写法如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

   ......
   自己的布局
   ......
   
   
</android.support.v4.widget.NestedScrollView>

<android.support.v7.widget.RecyclerView
    android:id="@+id/recycleView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

</RelativeLayout>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容