有时候我们需要实现ScrollView嵌套RecyclerView的效果:
<RelativeLayout>
<ScrollView android:id="@+id/myScrollView">
<LinearLayout>
<unrelated data>不相关的布局</unrealated data>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/my_recycler_view"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
有以下方法:
1. 使用NestedScrollView代替ScrollView
recyclerview.setNestedScrollingEnabled(false);
ViewHolder的高度:
android:layout_height="wrap_content"
参考:http://stackoverflow.com/questions/27083091/recyclerview-inside-scrollview-is-not-working
为RecyclerView增加Header
修改Adapter(未测试),参考:http://blog.csdn.net/revival_liang/article/details/52201099