Android技术知识Android开发

NestedScrollView和RecyclerView同时存

2016-11-09  本文已影响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>
上一篇 下一篇

猜你喜欢

热点阅读