RecyclerView
http://www.reibang.com/p/9ddfdffee5d3
http://www.reibang.com/p/4b8d6e5004d5
http://www.reibang.com/p/898479f103b6
http://www.reibang.com/p/f7f8814bd09a
http://www.reibang.com/p/6c78a5a07db5
NestedScrolling
http://blog.csdn.net/lmj623565791/article/details/52204039
http://www.race604.com/android-nested-scrolling/
RecyclerView 嵌套使用RecyclerView 并被CoordinatorLayout包裹時(shí)逮走,與SwipeRefreshLayout沖突且滑動(dòng)卡頓鸠蚪,是因?yàn)槭录职l(fā)時(shí)內(nèi)部的RecyclerView的onTouchEvent方法接收到cancel事件今阳,將SwipeRefreshLayout的NestedScrollingChildHelper中mNestedScrollingParent 值置為null师溅,導(dǎo)致nestedScrolling事件無法正確傳遞。
public class RecyclerView extends ViewGroup implements ScrollingView, NestedScrollingChild{
@Override
public boolean onTouchEvent(MotionEvent e) {
case MotionEvent.ACTION_CANCEL: {
cancelTouch();
}
private void cancelTouch() {
resetTouch();
setScrollState(SCROLL_STATE_IDLE);
}
private void resetTouch() {
if (mVelocityTracker != null) {
mVelocityTracker.clear();
}
stopNestedScroll();
releaseGlows();
}
@Override
public void stopNestedScroll() {
getScrollingChildHelper().stopNestedScroll();
}
}
public class NestedScrollingChildHelper {
public void stopNestedScroll() {
if (mNestedScrollingParent != null) {
ViewParentCompat.onStopNestedScroll(mNestedScrollingParent, mView);
mNestedScrollingParent = null;
}
}
}
可以自定義內(nèi)部RecyclerView重寫onTouch方法
public class CustomCancelRecyclerView extends RecyclerView {
@Override
public boolean onTouchEvent(MotionEvent e) {
return e.getAction() != MotionEvent.ACTION_CANCEL && super.onTouchEvent(e);
}
}
也可以給內(nèi)部RecyclerView設(shè)置onTouchListener
recyclerView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return event.getAction() == MotionEvent.ACTION_CANCEL;
}
});