DragLayout滑动冲突解决
This commit is contained in:
@@ -4,12 +4,10 @@ import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Created by huangmeng1 on 2018/3/7.
|
||||
* Updated by MadisonRong on 2018/4/23.
|
||||
@@ -54,6 +52,7 @@ public class DragLayout extends RelativeLayout {
|
||||
lastMoveY = lastY;
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
getParent().requestDisallowInterceptTouchEvent(true);
|
||||
dx = (int) event.getRawX() - lastX;
|
||||
dy = (int) event.getRawY() - lastY;
|
||||
|
||||
@@ -106,19 +105,18 @@ public class DragLayout extends RelativeLayout {
|
||||
}
|
||||
|
||||
private void reSetLayoutParams() {
|
||||
ViewGroup.MarginLayoutParams layoutParams = null;
|
||||
if (getLayoutParams() instanceof RelativeLayout.LayoutParams) {
|
||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
|
||||
layoutParams = new RelativeLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
layoutParams.leftMargin = left;
|
||||
layoutParams.topMargin = top;
|
||||
layoutParams.width = getWidth();
|
||||
layoutParams.height = getHeight();
|
||||
setLayoutParams(layoutParams);
|
||||
} else if (getLayoutParams() instanceof FrameLayout.LayoutParams) {
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||
layoutParams = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
}
|
||||
|
||||
if (layoutParams != null) {
|
||||
layoutParams.leftMargin = left;
|
||||
layoutParams.topMargin = top;
|
||||
layoutParams.width = getWidth();
|
||||
@@ -137,6 +135,7 @@ public class DragLayout extends RelativeLayout {
|
||||
lastMoveY = lastY;
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
getParent().requestDisallowInterceptTouchEvent(true);
|
||||
dx = (int) event.getRawX() - lastX;
|
||||
dy = (int) event.getRawY() - lastY;
|
||||
|
||||
|
Reference in New Issue
Block a user