解決方案:在布局中NestedScrollView
和RecyclerView
處于平級酪耕,將RecyclerView
放在在NestedScrollView
的下邊呜象,效果是RecyclerView
如果沒有加載到數(shù)據(jù)孽惰,此時事件交給NestedScrollView
處理晚岭,如果RecyclerView
加載到數(shù)事件交給RecyclerView
處理
這種一般是在實現(xiàn)懸停效果時候回出現(xiàn),請求網(wǎng)絡請求到數(shù)據(jù)列表展示勋功,斷網(wǎng)坦报,無數(shù)據(jù)等等其他狀態(tài)就會使用NestedScrollView库说,就可能出現(xiàn)該問題
具體寫法如下:
<?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>