當前位置: 首頁>>代碼示例>>Java>>正文


Java MotionEvent.ACTION_MOVE屬性代碼示例

本文整理匯總了Java中android.view.MotionEvent.ACTION_MOVE屬性的典型用法代碼示例。如果您正苦於以下問題:Java MotionEvent.ACTION_MOVE屬性的具體用法?Java MotionEvent.ACTION_MOVE怎麽用?Java MotionEvent.ACTION_MOVE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.view.MotionEvent的用法示例。


在下文中一共展示了MotionEvent.ACTION_MOVE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTouchAction

public static String getTouchAction(int actionId) {
	String actionName = "Unknow:id=" + actionId;
	switch (actionId) {
	case MotionEvent.ACTION_DOWN:
		actionName = "ACTION_DOWN";
		break;
	case MotionEvent.ACTION_MOVE:
		actionName = "ACTION_MOVE";
		break;
	case MotionEvent.ACTION_UP:
		actionName = "ACTION_UP";
		break;
	case MotionEvent.ACTION_CANCEL:
		actionName = "ACTION_CANCEL";
		break;
	case MotionEvent.ACTION_OUTSIDE:
		actionName = "ACTION_OUTSIDE";
		break;
	}
	return actionName;
}
 
開發者ID:wuhighway,項目名稱:DailyStudy,代碼行數:21,代碼來源:TouchEventUtil.java

示例2: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {

    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            Drawable drawable = getDrawable();
            if (drawable != null) {
                drawable.mutate().setColorFilter(Color.GRAY,
                        PorterDuff.Mode.MULTIPLY);
            }
            break;
        case MotionEvent.ACTION_MOVE:
            break;
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            Drawable drawableUp = getDrawable();
            if (drawableUp != null) {
                drawableUp.mutate().clearColorFilter();
            }
            break;
    }

    return super.onTouchEvent(event);
}
 
開發者ID:NICOLITE,項目名稱:HutHelper,代碼行數:24,代碼來源:RatioImageView.java

示例3: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    Log.i("ricky", "onIntercept");
    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            downX = ev.getRawX();
            lastMoveX = downX;
            requestParentDisallowInterceptTouchEvent(true);
            break;
        case MotionEvent.ACTION_MOVE:
            moveX = ev.getRawX();
            float xDiff = Math.abs(moveX - downX);
            lastMoveX = moveX;
            Log.i(TAG , "moveX:"+moveX+", xDiff:"+xDiff+", mTouchSlop:"+mTouchSlop);
            if (xDiff > mTouchSlop){
                return true;
            }
            break;

        default:
            break;
    }
    return super.onInterceptTouchEvent(ev);
}
 
開發者ID:AndryYu,項目名稱:EventDeliver,代碼行數:24,代碼來源:MyViewPager.java

示例4: onTouch

@Override
public boolean onTouch(View v, MotionEvent event) {
    switch (event.getAction()){
        case MotionEvent.ACTION_DOWN:
            Log.e("test","ACTION_DOWN");
            isTouching = true;
            break;

        case MotionEvent.ACTION_MOVE:
            Log.e("test","ACTION_MOVE");

            break;

        case MotionEvent.ACTION_UP:
            Log.e("test","ACTION_UP");
            isTouching = false;
            break;

        case MotionEvent.ACTION_CANCEL:
            Log.e("test","ACTION_CANCEL");
            isTouching = false;
            break;

    }
    return false;
}
 
開發者ID:4pp,項目名稱:downloader,代碼行數:26,代碼來源:DownLoadAdapter.java

示例5: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {

    int action = event.getAction();
    if (action == MotionEvent.ACTION_MOVE) {
        if (isStart) {
            isStart = false;
            if (onPullDownListener != null) {
                onPullDownListener.pullDownStart(event, this, listView);
            }
        }
        if (onPullDownListener != null) {
            onPullDownListener.pullDown(event, this, listView);
        }
    } else if (action == MotionEvent.ACTION_UP) {
        isStart = true;
        if (onPullDownListener != null) {
            onPullDownListener.pullDownSettle(event, this, listView);
        }
    }

    //ACTION_DOWN 事件時不攔截,點擊空白處時事件沒人處理最後會交回給自己,此時要讓接下來的事件繼續交給自己
    return false;
}
 
開發者ID:DuanJiaNing,項目名稱:Musicoco,代碼行數:24,代碼來源:PullDownLinearLayout.java

示例6: onTouch

@Override
public boolean onTouch(View v, MotionEvent event) {
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            mDownX = event.getRawX();
            mDownY = event.getRawY();
            isLongClicked = true;
            mBtnRecord.postDelayed(mLongClickRunnable, 500);
            break;
        case MotionEvent.ACTION_MOVE:
            if (Math.abs(mDownX - event.getRawX()) > mSlop || Math.abs(mDownY - event.getRawY()) > mSlop) {
                isLongClicked = false;
            }
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            isLongClicked = false;
            mCallback.onLift();
            break;
    }
    return true;
}
 
開發者ID:NullUsera,項目名稱:meipai-Android,代碼行數:22,代碼來源:RecordBtnWrapper.java

示例7: onTouch

boolean onTouch(MotionEvent ev) {
    if (ev.getAction() == MotionEvent.ACTION_DOWN) {
        getParent().requestDisallowInterceptTouchEvent(true);
        int additionWidth = (getMeasuredHeight() - thumbWidth) / 2;
        if (thumbX - additionWidth <= ev.getX() && ev.getX() <= thumbX + thumbWidth + additionWidth && ev.getY() >= 0 && ev.getY() <= getMeasuredHeight()) {
            pressed = true;
            thumbDX = (int)(ev.getX() - thumbX);
            invalidate();
            return true;
        }
    } else if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) {
        if (pressed) {
            if (ev.getAction() == MotionEvent.ACTION_UP) {
                onSeekBarDrag((float) thumbX / (float) (getMeasuredWidth() - thumbWidth));
            }
            pressed = false;
            invalidate();
            return true;
        }
    } else if (ev.getAction() == MotionEvent.ACTION_MOVE) {
        if (pressed) {
            thumbX = (int)(ev.getX() - thumbDX);
            if (thumbX < 0) {
                thumbX = 0;
            } else if (thumbX > getMeasuredWidth() - thumbWidth) {
                thumbX = getMeasuredWidth() - thumbWidth;
            }
            invalidate();
            return true;
        }
    }
    return false;
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:33,代碼來源:AudioPlayerActivity.java

示例8: onTouch

public boolean onTouch(int action, float x, float y) {
    if (action == MotionEvent.ACTION_DOWN) {
        int additionWidth = (height - thumbWidth) / 2;
        if (thumbX - additionWidth <= x && x <= thumbX + thumbWidth + additionWidth && y >= 0 && y <= height) {
            pressed = true;
            thumbDX = (int) (x - thumbX);
            return true;
        }
    } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
        if (pressed) {
            if (action == MotionEvent.ACTION_UP && delegate != null) {
                delegate.onSeekBarDrag((float) thumbX / (float) (width - thumbWidth));
            }
            pressed = false;
            return true;
        }
    } else if (action == MotionEvent.ACTION_MOVE) {
        if (pressed) {
            thumbX = (int) (x - thumbDX);
            if (thumbX < 0) {
                thumbX = 0;
            } else if (thumbX > width - thumbWidth) {
                thumbX = width - thumbWidth;
            }
            return true;
        }
    }
    return false;
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:29,代碼來源:SeekBar.java

示例9: onTouchEvent

/**
 * Handles the given motion event.
 * @param event event to handle
 * @return whether or not the event was handled
 */
public boolean onTouchEvent(final MotionEvent event) {
  switch (event.getActionMasked()) {
    case MotionEvent.ACTION_MOVE: {
      // update pointers
      updatePointersOnMove(event);
      // start a new gesture if not already started
      if (!mGestureInProgress && mPointerCount > 0 && shouldStartGesture()) {
        startGesture();
      }
      // notify listener
      if (mGestureInProgress && mListener != null) {
        mListener.onGestureUpdate(this);
      }
      break;
    }

    case MotionEvent.ACTION_DOWN:
    case MotionEvent.ACTION_POINTER_DOWN:
    case MotionEvent.ACTION_POINTER_UP:
    case MotionEvent.ACTION_UP: {
      // restart gesture whenever the number of pointers changes
      mNewPointerCount = getPressedPointerCount(event);
      stopGesture();
      updatePointersOnTap(event);
      if (mPointerCount > 0 && shouldStartGesture()) {
        startGesture();
      }
      break;
    }

    case MotionEvent.ACTION_CANCEL: {
      mNewPointerCount = 0;
      stopGesture();
      reset();
      break;
    }
  }
  return true;
}
 
開發者ID:idisfkj,項目名稱:Zoomable,代碼行數:44,代碼來源:MultiPointerGestureDetector.java

示例10: onInterceptTouchEvent

/**
 * @see ListView#onInterceptTouchEvent(MotionEvent)
 */
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    int action = MotionEventCompat.getActionMasked(ev);
    final float x = ev.getX();
    final float y = ev.getY();

    if (isEnabled() && touchListener.isSwipeEnabled()) {

        if (touchState == TOUCH_STATE_SCROLLING_X) {
            return touchListener.onTouch(this, ev);
        }

        switch (action) {
            case MotionEvent.ACTION_MOVE:
                checkInMoving(x, y);
                return touchState == TOUCH_STATE_SCROLLING_Y;
            case MotionEvent.ACTION_DOWN:
                super.onInterceptTouchEvent(ev);
                touchListener.onTouch(this, ev);
                touchState = TOUCH_STATE_REST;
                lastMotionX = x;
                lastMotionY = y;
                return false;
            case MotionEvent.ACTION_CANCEL:
                touchState = TOUCH_STATE_REST;
                break;
            case MotionEvent.ACTION_UP:
                touchListener.onTouch(this, ev);
                return touchState == TOUCH_STATE_SCROLLING_Y;
            default:
                break;
        }
    }

    return super.onInterceptTouchEvent(ev);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:39,代碼來源:SwipeListView.java

示例11: dispatchTouchEvent

@Override
public boolean dispatchTouchEvent(MotionEvent event) {


    if (mActivityCallback == null)
        mActivityCallback = (ReadEPubActivity) getContext();

    final int action = event.getAction();
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            mMoveOccured = false;
            mDownPosX = event.getX();
            mDownPosY = event.getY();
            fragment.removeCallback();
            break;
        case MotionEvent.ACTION_UP:
            if (!mMoveOccured) {
                mActivityCallback.toggleToolBarVisible();
            }

            fragment.startCallback();
            break;
        case MotionEvent.ACTION_MOVE:
            if (Math.abs(event.getX() - mDownPosX) > MOVE_THRESHOLD_DP
                    || Math.abs(event.getY() - mDownPosY) > MOVE_THRESHOLD_DP) {
                mMoveOccured = true;
                fragment.fadeInSeekbarIfInvisible();
            }
            break;
    }

    return super.dispatchTouchEvent(event);
}
 
開發者ID:ynztlxdeai,項目名稱:TextReader,代碼行數:33,代碼來源:ObservableWebView.java

示例12: getPanEventAction

private String getPanEventAction(MotionEvent event) {
  switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
      return START;
    case MotionEvent.ACTION_MOVE:
      return MOVE;
    case MotionEvent.ACTION_UP:
      return END;
    case MotionEvent.ACTION_CANCEL:
      return END;
    default:
      return UNKNOWN;
  }
}
 
開發者ID:weexext,項目名稱:ucar-weex-core,代碼行數:14,代碼來源:WXGesture.java

示例13: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (Build.VERSION.SDK_INT >= 21 && getBackground() != null) {
        if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) {
            getBackground().setHotspot(event.getX(), event.getY());
        }
    }
    return super.onTouchEvent(event);
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:9,代碼來源:FeaturedStickerSetCell.java

示例14: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent ev) {
    if (mDynamicViewHeight == 0) {
        mDynamicViewHeight = mDynamicView.getHeight();
    }

    if (mValueAnimator != null && mValueAnimator.isRunning()) {
        return true;
    }

    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            mDownY = ev.getRawY();
            break;
        case MotionEvent.ACTION_MOVE:
            float moveY = ev.getRawY();
            float dy = moveY - mDownY;
            mDownY = moveY;
            boolean handleMotionEvent = handleActionMove(dy);// consume the event ?
            if (handleMotionEvent) {
                return true;
            }
            break;
        case MotionEvent.ACTION_UP:
            boolean handleMoveUp = handleActionUp(ev.getRawY());
            if (handleMoveUp) {
                return true;
            }
            break;
        default:
            handleActionUp(ev.getRawY());
            break;
    }

    return super.onTouchEvent(ev);
}
 
開發者ID:yongfengnice,項目名稱:DynamicHeadView,代碼行數:36,代碼來源:DynamicHeadRecyclerView.java

示例15: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent ev) {
    boolean returnValue = false;

    MotionEvent event = MotionEvent.obtain(ev);
    final int action = MotionEventCompat.getActionMasked(event);
    if (action == MotionEvent.ACTION_DOWN) {
        mNestedOffsetY = 0;
    }
    int eventY = (int) event.getY();
    event.offsetLocation(0, mNestedOffsetY);
    switch (action) {
        case MotionEvent.ACTION_MOVE:
            int deltaY = mLastY - eventY;
            // NestedPreScroll
            if (dispatchNestedPreScroll(0, deltaY, mScrollConsumed, mScrollOffset)) {
                deltaY -= mScrollConsumed[1];
                mLastY = eventY - mScrollOffset[1];
                event.offsetLocation(0, -mScrollOffset[1]);
                mNestedOffsetY += mScrollOffset[1];
            }
            returnValue = super.onTouchEvent(event);

            // NestedScroll
            if (dispatchNestedScroll(0, mScrollOffset[1], 0, deltaY, mScrollOffset)) {
                event.offsetLocation(0, mScrollOffset[1]);
                mNestedOffsetY += mScrollOffset[1];
                mLastY -= mScrollOffset[1];
            }
            break;
        case MotionEvent.ACTION_DOWN:
            returnValue = super.onTouchEvent(event);
            mLastY = eventY;
            // start NestedScroll
            startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL);
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            returnValue = super.onTouchEvent(event);
            // end NestedScroll
            stopNestedScroll();
            break;
    }
    return returnValue;
}
 
開發者ID:fendoudebb,項目名稱:PlayAndroid,代碼行數:45,代碼來源:NestedWebView.java


注:本文中的android.view.MotionEvent.ACTION_MOVE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。