We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
private void chkDragable() { setOnTouchListener(new View.OnTouchListener() { @OverRide public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { lastY = motionEvent.getRawY(); lastX = motionEvent.getRawX(); } else if (motionEvent.getAction() == MotionEvent.ACTION_MOVE) { newY = motionEvent.getRawY();
---------------------"lastX = motionEvent.getRawX();"------------------------
offsetY = Math.abs(newY - lastY); lastY = newY; offsetX = Math.abs(newX - lastX); lastX = newX; switch (dragEdge) { case TOP: case BOTTOM: setEnablePullToBack(offsetY > offsetX); case LEFT: case RIGHT: setEnablePullToBack(offsetY < offsetX); break; } } return false; } }); }
}
标注的地方, 应该是 newX = motionEvent.getRawX(); 但是修改之后, 拖拽就失效了
The text was updated successfully, but these errors were encountered:
我这对做了些处理,拖拽失效我看了下,应该是ViewDragHelper 中 tryCaptureViewForDrag()方法里获取mCallback.tryCaptureView()的回调判断在 Touch方法之前先执行而在newX = motionEvent.getRawX();之后若有false返回一次,那下一次一直就以false返回,onInterceptTouchEvent() 就一直返回false,导致拖拽失效。
我这边的处理 @OverRide public boolean onInterceptTouchEvent(MotionEvent ev) { boolean handled = false; ensureTarget(); checkPullBack(ev);//在这里加上touch方法里的偏移判断 if (isEnabled()) { handled = viewDragHelper.shouldInterceptTouchEvent(ev); } else { viewDragHelper.cancel(); } return !handled ? super.onInterceptTouchEvent(ev) : handled; }
Sorry, something went wrong.
No branches or pull requests
private void chkDragable() {
setOnTouchListener(new View.OnTouchListener() {
@OverRide
public boolean onTouch(View view, MotionEvent motionEvent) {
---------------------"lastX = motionEvent.getRawX();"------------------------
}
标注的地方, 应该是
newX = motionEvent.getRawX();
但是修改之后, 拖拽就失效了
The text was updated successfully, but these errors were encountered: