@Override public boolean tryCaptureView(View child, int pointerId) { isCaptureAbort = false; if (!enableSwipeBack) { return false; } if (child == null || child.getLeft() != 0 || child.getTranslationX() != 0f || mViewDragState != ViewDragHelper.STATE_IDLE) { return false; } mIsLeftEdge = mDragHelper.isEdgeTouched(ViewDragHelper.EDGE_LEFT, pointerId); mTargetView = child; if (mIsLeftEdge || isForceIntercept()) { return canTryCaptureView(child); } return false; }
@Override public boolean tryCaptureView(View child, int pointerId) { boolean edgeTouched = mDragHelper.isEdgeTouched(mEdgeFlag, pointerId); if (edgeTouched) { if (mDragHelper.isEdgeTouched(EDGE_LEFT, pointerId)) { mTrackingEdge = EDGE_LEFT; } else if (mDragHelper.isEdgeTouched(EDGE_RIGHT, pointerId)) { mTrackingEdge = EDGE_RIGHT; } else if (mDragHelper.isEdgeTouched(EDGE_BOTTOM, pointerId)) { mTrackingEdge = EDGE_BOTTOM; } } boolean directionCheck = false; if (mEdgeFlag == EDGE_LEFT || mEdgeFlag == EDGE_RIGHT) { // 左右边缘则检测竖直方向的滑动 directionCheck = !mDragHelper.checkTouchSlop(ViewDragHelper.DIRECTION_VERTICAL, pointerId); } else if (mEdgeFlag == EDGE_BOTTOM) { // 下边缘则检测水平方向的滑动 directionCheck = !mDragHelper.checkTouchSlop(ViewDragHelper.DIRECTION_HORIZONTAL, pointerId); } else if (mEdgeFlag == EDGE_ALL) { directionCheck = true; } return edgeTouched && directionCheck; }
public DragLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.app, 0, 0); bottomDragVisibleHeight = (int) a.getDimension(R.styleable.app_bottomDragVisibleHeight, 0); bototmExtraIndicatorHeight = (int) a.getDimension(R.styleable.app_bototmExtraIndicatorHeight, 0); a.recycle(); mDragHelper = ViewDragHelper .create(this, 10f, new DragHelperCallback()); mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_TOP); moveDetector = new GestureDetectorCompat(context, new MoveDetector()); moveDetector.setIsLongpressEnabled(false); // 不处理长按事件 // 滑动的距离阈值由系统提供 ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); }
@Override public void onViewDragStateChanged(int state) { if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) { if (mSlideOffset == 0) { updateObscuredViewsVisibility(mSlideableView); dispatchOnPanelClosed(mSlideableView); mPreservedOpenState = false; } else { dispatchOnPanelOpened(mSlideableView); mPreservedOpenState = true; } // ======================== 新加的 START ======================== // } mIsSliding = false; } else { mIsSliding = true; } // ======================== 新加的 END ======================== }
public BGASwipeBackLayout2(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final float density = context.getResources().getDisplayMetrics().density; // ======================== 新加的 START ======================== // mOverhangSize = (int) (DEFAULT_OVERHANG_SIZE * density + 0.5f); mOverhangSize = 0; // ======================== 新加的 END ======================== final ViewConfiguration viewConfig = ViewConfiguration.get(context); setWillNotDraw(false); ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate()); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback()); mDragHelper.setMinVelocity(MIN_FLING_VELOCITY * density); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup view = (ViewGroup) inflater.inflate(R.layout.fragment_square, container, false); mCardView = (CardView) view.findViewById(R.id.card_view); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mCardZ = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2.f, getResources().getDisplayMetrics()); mCardView.setZ(mCardZ); } final ViewDragHelper viewDragHelper = ViewDragHelper.create(view, mViewDragHelperCallback); view.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { viewDragHelper.processTouchEvent(event); return false; } }); recordOriginalLocation(mCardView); return view; }
/** * Method for increasing a Navigation Drawer's edge size. */ public static void increaseNavigationDrawerEdge(DrawerLayout aDrawerLayout, Context context) { // Increase the area from which you can open the navigation drawer. try { Field mDragger = aDrawerLayout.getClass().getDeclaredField("mLeftDragger"); mDragger.setAccessible(true); ViewDragHelper draggerObj = (ViewDragHelper) mDragger.get(aDrawerLayout); Field mEdgeSize = draggerObj.getClass().getDeclaredField("mEdgeSize"); mEdgeSize.setAccessible(true); int edgeSize = mEdgeSize.getInt(draggerObj) * 3; mEdgeSize.setInt(draggerObj, edgeSize); //optimal value as for me, you may set any constant in dp } catch(Exception e) { e.printStackTrace(); } }
/** * Checks dragging states and notifies them. */ @Override public void onViewDragStateChanged(int state) { // If no state change, don't do anything if (state == lastDraggingState) { return; } // If last state was dragging or settling and current state is idle, // the view has stopped moving. If the top border of the container is // equal to the vertical draggable range, the view has being dragged out, // so close activity is called if ((lastDraggingState == ViewDragHelper.STATE_DRAGGING || lastDraggingState == ViewDragHelper.STATE_SETTLING) && state == ViewDragHelper.STATE_IDLE && topBorderDraggableContainer == dragToClose.getDraggableRange()) { dragToClose.closeActivity(); } // If the view has just started being dragged, notify event if (state == ViewDragHelper.STATE_DRAGGING) { dragToClose.onStartDraggingView(); } // Save current state lastDraggingState = state; }
private void init(Context context, AttributeSet attrs) { //获取相关属性设置 TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlideLayout); mAlphaColor = ta.getColor(R.styleable.SlideLayout_sl_anim_alpha_color, DEF_ANIM_ALPHA_COLOR); mEdgeEnable = ta.getBoolean(R.styleable.SlideLayout_sl_edge_enable, DEF_EDGE_ENABLE); mMainAlphaEnable = ta.getBoolean(R.styleable.SlideLayout_sl_main_alpha_enable, DEF_MAIN_ALPHA_ENABLE); ta.recycle(); //初始化ViewDragHelper相关 mCallback = new DragCallback(); mDragHelper = ViewDragHelper.create(this, DEF_SENSITIVITY, mCallback); if (mEdgeEnable) { //设置边缘滑动检测 mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT); //设置最小滑动速度 mDragHelper.setMinVelocity(DEF_SENSITIVITY * DEF_MIN_FLING_VELOCITY); } //初始化屏幕触控处理相关 mGestureListener = new GestureListener(); mGestureDetector = new GestureDetectorCompat(context, mGestureListener); //设置初始状态为关闭 mStatus = Status.CLOSED; }
/** * \ * 通过xml布局 自定义属性调用 * * @param context 上下文 * @param attrs xml属性 */ public SwipeBackLayout(Context context, AttributeSet attrs) { super(context, attrs); //①获取ViewDragHelper的实例 mViewDragHelper = ViewDragHelper.create(this, 1.0f, new ViewDragHelperCallback()); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SwipeBackLayout); mDragDirectionMask = ta.getInt(R.styleable.SwipeBackLayout_dragDirection, NONE); mShadowColor = ta.getColor(R.styleable.SwipeBackLayout_shadowColor, mShadowColor); int contentLayoutId = ta.getResourceId(R.styleable.SwipeBackLayout_contentView,View.NO_ID); ta.recycle(); addShadowView(context); if (View.NO_ID != contentLayoutId){ mContentView = LayoutInflater.from(context).inflate(contentLayoutId, this, false); addView(mContentView); } enableSwipeBack = true; }
private int getTopLayoutHeaderView() { // 初始值 int top = getTopHeaderViewReset(); if (getDirection() == Direction.FROM_HEADER) { if (mViewDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) { switch (mState) { case REFRESHING: case REFRESH_SUCCESS: case REFRESH_FAILURE: top += mHeaderView.getRefreshHeight(); break; } } else { top = mHeaderView.getTop(); } } return top; }
private int getTopLayoutFooterView() { // 初始值 int top = getTopFooterViewReset(); if (getDirection() == Direction.FROM_FOOTER) { if (mViewDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) { switch (mState) { case REFRESHING: case REFRESH_SUCCESS: case REFRESH_FAILURE: top -= mFooterView.getRefreshHeight(); break; } } else { top = mFooterView.getTop(); } } return top; }
public DraggableSquareView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mDragHelper = ViewDragHelper .create(this, 10f, new DragHelperCallback()); moveDetector = new GestureDetectorCompat(context, new MoveDetector()); moveDetector.setIsLongpressEnabled(false); // 不能处理长按事件,否则违背最初设计的初衷 spaceInterval = (int) getResources().getDimension(R.dimen.drag_square_interval); // 小方块之间的间隔 // 滑动的距离阈值由系统提供 ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); anchorHandler = new Handler() { @Override public void handleMessage(Message msg) { if (draggingView != null) { // 开始移动重心的动画 draggingView.startAnchorAnimation(); } } }; }
private void setDrawerLeftEdgeSize (Context context, DrawerLayout drawerLayout, float displayWidthPercentage) { if (context == null || drawerLayout == null) return; try { // 找到 ViewDragHelper 并设置 Accessible 为true Field leftDraggerField = drawerLayout.getClass().getDeclaredField("mRightDragger");//Right leftDraggerField.setAccessible(true); ViewDragHelper leftDragger = (ViewDragHelper) leftDraggerField.get(drawerLayout); // 找到 edgeSizeField 并设置 Accessible 为true Field edgeSizeField = leftDragger.getClass().getDeclaredField("mEdgeSize"); edgeSizeField.setAccessible(true); int edgeSize = edgeSizeField.getInt(leftDragger); // 设置新的边缘大小 int screenWidth = PixelUtil.getWidth(context); edgeSizeField.setInt(leftDragger, Math.max(edgeSize, (int) (screenWidth * displayWidthPercentage))); } catch (Exception e) { Log.e("aaa", "setDrawerLeftEdgeSize wrong"); } }
public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) { if (!(this.mState == 1 || this.mState == 2)) { parent.onLayoutChild(child, layoutDirection); } this.mParentHeight = parent.getHeight(); this.mMinOffset = Math.max(0, this.mParentHeight - child.getHeight()); this.mMaxOffset = Math.max(this.mParentHeight - this.mPeekHeight, this.mMinOffset); if (this.mState == 3) { ViewCompat.offsetTopAndBottom(child, this.mMinOffset); } else if (this.mHideable && this.mState == 5) { ViewCompat.offsetTopAndBottom(child, this.mParentHeight); } else if (this.mState == 4) { ViewCompat.offsetTopAndBottom(child, this.mMaxOffset); } if (this.mViewDragHelper == null) { this.mViewDragHelper = ViewDragHelper.create(parent, this.mDragCallback); } this.mViewRef = new WeakReference(child); this.mNestedScrollingChildRef = new WeakReference(findScrollingChild(child)); return true; }
public SideMenu(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final float density = context.getResources().getDisplayMetrics().density; mOverhangSize = (int) (DEFAULT_OVERHANG_SIZE * density + 0.5f); final ViewConfiguration viewConfig = ViewConfiguration.get(context); setWillNotDraw(false); ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate()); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback()); mDragHelper.setMinVelocity(MIN_FLING_VELOCITY * density); setPanelSlideListener(new SimpleMenuPanelSlideListener()); setSliderFadeColor(ContextCompat.getColor(context, android.R.color.transparent)); setParallaxDistance(PARALLAX_DISTANCE); }
@Override public void onViewDragStateChanged(int state) { if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) { if (mSlideOffset == 0) { updateObscuredViewsVisibility(mSlideableView); dispatchOnPanelClosed(mSlideableView); mPreservedOpenState = false; } else { dispatchOnPanelOpened(mSlideableView); mPreservedOpenState = true; } } }
@Override public void onViewDragStateChanged(int state) { if (state == draggingState) return; if ((draggingState == ViewDragHelper.STATE_DRAGGING || draggingState == ViewDragHelper.STATE_SETTLING) && state == ViewDragHelper.STATE_IDLE) { // the view stopped from moving. if (draggingOffset == getDragRange()) { finish(); } } draggingState = state; }
@Override public void onViewReleased(View releasedChild, float xvel, float yvel) { super.onViewReleased(releasedChild, xvel, yvel); if (mCurEdgeFlag == ViewDragHelper.EDGE_LEFT) { if (mCurrentX > getWidth() / 2) { mViewDragHelper.settleCapturedViewAt(getWidth(), 0); } else { mViewDragHelper.settleCapturedViewAt(0, 0); mCurrentX = 0; } invalidate(); } }
@Override public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) { super.onViewPositionChanged(changedView, left, top, dx, dy); if (mCurEdgeFlag == ViewDragHelper.EDGE_LEFT) { if (mOnScrollListener != null) mOnScrollListener.complete((float) (Math.abs(left) * 1.00 / getWidth())); if (left >= getWidth()) finish(); } }
@Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { final boolean drawContent = child == mContentView; boolean ret = super.drawChild(canvas, child, drawingTime); if (mScrimOpacity > 0 && drawContent && mDragHelper.getViewDragState() != ViewDragHelper.STATE_IDLE) { drawShadow(canvas, child); drawScrim(canvas, child); } return ret; }
@Override public void onViewDragStateChanged(int state) { super.onViewDragStateChanged(state); if (state == ViewDragHelper.STATE_IDLE) { mTrackingEdge = EDGE_INVALID; } }
@Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { final boolean drawContent = child == mContentView; final boolean ret = super.drawChild(canvas, child, drawingTime); if (mScrimOpacity > 0 && drawContent && mDragHelper.getViewDragState() != ViewDragHelper.STATE_IDLE) { drawScrim(canvas, child); } return ret; }
public SwipeToRefreshLayout(@NonNull Context context, @NonNull View contentView, int directionMask) { super(context); mViewDragHelper = ViewDragHelper.create(this, 1.0f, new ViewDragHelperCallback()); mContentView = contentView; mDirectionMask = directionMask; enableSwipe = true; }
@Override public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) { // First let the parent lay it out if (mState != STATE_DRAGGING && mState != STATE_SETTLING) { if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) { ViewCompat.setFitsSystemWindows(child, true); } parent.onLayoutChild(child, layoutDirection); } // Offset the bottom sheet mParentHeight = parent.getHeight(); mMinOffset = Math.max(0, mParentHeight - child.getHeight()); mMaxOffset = Math.max(mParentHeight - mPeekHeight, mMinOffset); /** * New behavior */ if (mState == STATE_ANCHOR_POINT) { ViewCompat.offsetTopAndBottom(child, mAnchorPoint); } else if (mState == STATE_EXPANDED) { ViewCompat.offsetTopAndBottom(child, mMinOffset); } else if (mHideable && mState == STATE_HIDDEN) { ViewCompat.offsetTopAndBottom(child, mParentHeight); } else if (mState == STATE_COLLAPSED) { ViewCompat.offsetTopAndBottom(child, mMaxOffset); } if (mViewDragHelper == null) { mViewDragHelper = ViewDragHelper.create(parent, mDragCallback); } mViewRef = new WeakReference<>(child); mNestedScrollingChildRef = new WeakReference<>(findScrollingChild(child)); return true; }
@Override public void onViewDragStateChanged(int state) { super.onViewDragStateChanged(state); if (mListener != null) mListener.onStateChanged(state); SwipeBackLayout.this.onViewDragStateChanged(state); switch (state) { case ViewDragHelper.STATE_IDLE: onStateIdle(); if (isCaptureAbort) { onRequestOpened(); } else { //滚动结束 if (mTargetView.getLeft() < getMinCloseWidth()) { // State Open onRequestOpened(); if (mListener != null) mListener.onRequestOpened(); } else { // State Closed onRequestClose(); if (mListener != null) mListener.onRequestClose(); } mTargetView = null; } isCaptureAbort = false; break; case ViewDragHelper.STATE_DRAGGING: //开始滚动 onStateDragging(); break; case ViewDragHelper.STATE_SETTLING: //滑行中... break; } }
public SwipeDrawerLayout(@NonNull Context context, @NonNull View contentView, int directionMask) { super(context); mViewDragHelper = ViewDragHelper.create(this, 1.0f, new ViewDragHelperCallback()); mContentView = contentView; mDirectionMask = directionMask; enableSwipe = true; }
public QuickAttachmentDrawer(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); dragHelper = ViewDragHelper.create(this, 1.f, new ViewDragHelperCallback()); initializeView(); updateHalfExpandedAnchorPoint(); onConfigurationChanged(); }
public OverScrollLayout(@NonNull Context context, @NonNull View contentView, int directionMask) { super(context); mViewDragHelper = ViewDragHelper.create(this, 1.0f, new ViewDragHelperCallback()); mContentView = contentView; mDirectionMask = directionMask; enableSwipe = true; }
@Override public void onViewDragStateChanged(int state) { super.onViewDragStateChanged(state); if (mLastDragState == ViewDragHelper.STATE_SETTLING && state == ViewDragHelper.STATE_DRAGGING) { if (mViewDragHelper.smoothSlideViewTo(mContentView, mOriginX, mOriginY)) { ViewCompat.postInvalidateOnAnimation(OverScrollLayout.this); } } if (state == ViewDragHelper.STATE_IDLE) { mCurrentDirection = NONE; } Log.e("zhou","==============onViewDragStateChanged=================="+state); mLastDragState = state; }
/** * 根据状态改变view * * @param anim */ private void updateViewByState(boolean anim) { int left = mIsChecked ? getLeftChecked() : getLeftNormal(); if (mViewThumb.getLeft() != left) { if (mIsDebug) { Log.i(TAG, "updateViewByState anim:" + anim); } if (anim) { mViewDragHelper.smoothSlideViewTo(mViewThumb, left, mViewThumb.getTop()); } else { mViewThumb.layout(left, mViewThumb.getTop(), left + mViewThumb.getMeasuredWidth(), mViewThumb.getBottom()); } invalidate(); } if (mViewDragHelper.getViewDragState() == ViewDragHelper.STATE_SETTLING) { //触发滚动成功,不需要立即更新view的可见状态,动画结束后更新 mIsScrollerStarted = true; } else { // 立即更新view的可见状态 updateViewVisibilityByState(); } mViewThumb.setSelected(mIsChecked); if (mOnViewPositionChangedCallback != null) { mOnViewPositionChangedCallback.onViewPositionChanged(FSwitchButton.this); } }
protected void onSlideStateChanged(int state) { if(getWindowIsTranslucent()){ return; } if (state == ViewDragHelper.STATE_DRAGGING) { Drawable windowBackground = getWindowBackground(); if (windowBackground != null) { getWindow().setBackgroundDrawable(windowBackground); } else { getWindow().setBackgroundDrawable(getDefaultWindowBackground()); } } }
@Override public void onViewDragStateChanged(int state) { if (dragHelper.getViewDragState() == ViewDragHelper.STATE_IDLE) { setDrawerState(drawerState); slideOffset = getTargetSlideOffset(); requestLayout(); } }
@Override public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) { if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) { ViewCompat.setFitsSystemWindows(child, true); } int savedTop = child.getTop(); // First let the parent lay it out parent.onLayoutChild(child, layoutDirection); // Offset the bottom sheet mParentHeight = parent.getHeight(); int peekHeight; if (mPeekHeightAuto) { if (mPeekHeightMin == 0) { mPeekHeightMin = parent.getResources().getDimensionPixelSize( R.dimen.design_bottom_sheet_peek_height_min); } peekHeight = Math.max(mPeekHeightMin, mParentHeight - parent.getWidth() * 9 / 16); } else { peekHeight = mPeekHeight; } mMinOffset = Math.max(0, mParentHeight - child.getHeight()); mMaxOffset = Math.max(mParentHeight - peekHeight, mMinOffset); if (mState == STATE_EXPANDED) { ViewCompat.offsetTopAndBottom(child, mMinOffset); } else if (mHideable && mState == STATE_HIDDEN) { ViewCompat.offsetTopAndBottom(child, mParentHeight); } else if (mState == STATE_COLLAPSED) { ViewCompat.offsetTopAndBottom(child, mMaxOffset); } else if (mState == STATE_DRAGGING || mState == STATE_SETTLING) { ViewCompat.offsetTopAndBottom(child, savedTop - child.getTop()); } if (mViewDragHelper == null) { mViewDragHelper = ViewDragHelper.create(parent, mDragCallback); } mViewRef = new WeakReference<>(child); mNestedScrollingChildRef = new WeakReference<>(findScrollingChild(child)); return true; }
private void reset() { mActivePointerId = ViewDragHelper.INVALID_POINTER; if (mVelocityTracker != null) { mVelocityTracker.recycle(); mVelocityTracker = null; } }
public SnakeButtonLayout(Context context, AttributeSet attrs) { super(context, attrs); marginRight = PUtils.getInstance().getMarginRight(); marginBottom = PUtils.getInstance().getMarginBottom(); isVisible = PUtils.getInstance().getVisible(); mDragHelper = ViewDragHelper.create(this, 10f, new MyViewDragCallBack()); controller = ViewController.getInstance(); }
public DragLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mGestureDetector = new GestureDetector(context, new SimpleOnGestureListener() { @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { // 如果水平方向的偏移量大于竖直方向的偏移量,就消化该事件, return Math.abs(distanceX) > Math.abs(distanceY) || super.onScroll(e1, e2, distanceX, distanceY); } }); // 永远要记得,该工具实现的拖拉是基于控件位置的改变来实现的 mViewDragHelper = ViewDragHelper.create(this, new DragViewCallBack()); }
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { // 如果符合条件直接截获事件由自己在onTouchEvent方法中处理 // 如果在释放自动滑动的过程中点击,会导致停止动画 boolean result = mViewDragHelper.shouldInterceptTouchEvent(ev) && mGestureDetector.onTouchEvent(ev); // 这里是为了防止在滑动的过程中,突然点击,导致被点击的页面停止滑动的的情况发生 if (!result && mViewDragHelper.getViewDragState() == ViewDragHelper.STATE_DRAGGING && ev.getAction() == MotionEvent.ACTION_UP) { if (getChildAt(2).getLeft() < range / 2) { closeMenu(); } else { openMenu(); } } return result; }