首先是在代码设置样式布局那里。设置该方法,GridLayoutManager和瀑布流等同。
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context) {
@Override
public boolean canScrollVertically() {
return false;
}
};
其次在XML管理布局里面,在使用到recycleview的布局外用一个RelativeLayout,
关键属性android:descendantFocusability=“blocksDescendants”
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">
<android.support.v7.widget.RecyclerView
android:id="@+id/mRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>