当前位置: 首页>>代码示例>>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;未经允许,请勿转载。