1,先解決第一個recyclerview不能完整顯示的問題
在倆個recyclerview外面都包裹一個相對佈局RelativeLayout,一定是倆個recyclerview都要包裹。我試着只包裹下底部的一個,發現當底部的數據增多時,會出現異常。
2,當第二個recyclerview部分超出屏幕時,滑動時只有recyclerView,scrollview不會動
原因還是滑動衝突的問題,我的解決方案是,重寫LinearLayoutManager,設置讓其不可滑動,外部滑動靠ScrollView
public class ScrollGridLayoutManager extends GridLayoutManager{
private boolean isScrollEnabled = true;
public ScrollGridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
public ScrollGridLayoutManager(Context context, int spanCount) {
super(context, spanCount);
}
public ScrollGridLayoutManager(Context context, int spanCount, int orientation, boolean reverseLayout) {
super(context, spanCount, orientation, reverseLayout);
}
@Override
public boolean canScrollVertically() {
return super.canScrollVertically() && isScrollEnabled;
}
public void setScrollEnabled(boolean flag) {
this.isScrollEnabled = flag;
}
}