版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_30512027/article/details/81194272
HorizontalListView的github地址:https://github.com/chengbiao1314/android_myview_HorizontalListView
https://github.com/MeetMe/Android-HorizontalListView
设置为wrap_content控件不显示时设置一下固定高度
滑动冲突:
private int mLastX;
private int mLastY;
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
int x = (int) ev.getX();
int y = (int) ev.getY();
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_MOVE:
int xDiff = Math.abs(x - mLastX);
int yDiff = Math.abs(y - mLastY);
if (xDiff < yDiff) {
getParent().requestDisallowInterceptTouchEvent(false);
} else {
getParent().requestDisallowInterceptTouchEvent(true);
}
break;
}
mLastX = x;
mLastY = y;
return super.dispatchTouchEvent(ev);
}