reference to : http://zhanglu0574.blog.163.com/blog/static/113651073201641853532259/ide
一個界面有多個RecyclerView以及其餘一些內容,這 時要上下滾動就會使用外面嵌套一個ScrollView,雖然我沒有遇到像ScrollView嵌套ListView時那樣只顯示部分,剩餘不顯示,可能 是由於我內容少吧,因此沒有遇到這個,可是在滑動的時候若是是在RecyclerView上滑動,這時會出現只滑動動該RecyclerView的內容上 就會中止,而若是是在其餘內容上滑動時就能夠很順暢的滑下去,所以就會感受到卡頓的樣子。this
linearLayoutManager = new LinearLayoutManager(context) {
@Override
public boolean canScrollVertically() {
return false;
}
};
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);
}
public void setScrollEnabled(boolean flag) {
this.isScrollEnabled = flag;
}
@Override
public boolean canScrollVertically() {
//Similarly you can customize "canScrollHorizontally()" for managing horizontal scroll
return isScrollEnabled && super.canScrollVertically();
}}