美文网首页Android技术知识Android开发
NestedScrollView和RecyclerView同时存

NestedScrollView和RecyclerView同时存

作者: 秦小怪 | 来源:发表于2016-11-09 16:37 被阅读0次

解决方案:在布局中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>

相关文章

网友评论

    本文标题:NestedScrollView和RecyclerView同时存

    本文链接:https://www.haomeiwen.com/subject/wlctpttx.html