android.view.MotionEvent.getRawY()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(225)

本文整理了Java中android.view.MotionEvent.getRawY()方法的一些代码示例,展示了MotionEvent.getRawY()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MotionEvent.getRawY()方法的具体详情如下:
包路径:android.view.MotionEvent
类名称:MotionEvent
方法名:getRawY

MotionEvent.getRawY介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

float dX, dY;

@Override
public boolean onTouch(View view, MotionEvent event) {

  switch (event.getAction()) {

    case MotionEvent.ACTION_DOWN:

      dX = view.getX() - event.getRawX();
      dY = view.getY() - event.getRawY();
      break;

    case MotionEvent.ACTION_MOVE:

      view.animate()
          .x(event.getRawX() + dX)
          .y(event.getRawY() + dY)
          .setDuration(0)
          .start();
      break;
    default:
      return false;
  }
  return true;
}

代码示例来源:origin: stackoverflow.com

protected Point getRelativePosition(View v, MotionEvent event) {
  int[] location = new int[2];
  v.getLocationOnScreen(location);
  float screenX = event.getRawX();
  float screenY = event.getRawY();
  float viewX = screenX - location[0];
  float viewY = screenY - location[1];
  return new Point((int) viewX, (int) viewY);
}

代码示例来源:origin: jiangqqlmj/FastDev4Android

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
  final int action = event.getAction();
  switch (action) {
    case MotionEvent.ACTION_DOWN:
      // 按下
      mYDown = (int) event.getRawY();
      break;
    case MotionEvent.ACTION_MOVE:
      // 移动
      mLastY = (int) event.getRawY();
      break;
    case MotionEvent.ACTION_UP:
      // 抬起
      if (canLoad()) {
        loadData();
      }
      break;
    default:
      break;
  }
  return super.dispatchTouchEvent(event);
}

代码示例来源:origin: aa112901/remusic

@Override  
public boolean onTouch(View v, MotionEvent event) {  
  switch (event.getAction()) {  
  case MotionEvent.ACTION_DOWN:  
    downX = tempX = (int) event.getRawX();  
    downY = (int) event.getRawY();  
    break;  
  case MotionEvent.ACTION_MOVE:  
    int moveX = (int) event.getRawX();  
    int deltaX = tempX - moveX;  
    tempX = moveX;  
    if (Math.abs(moveX - downX) > mTouchSlop  
        && Math.abs((int) event.getRawY() - downY) < mTouchSlop) {  
      isSilding = true;

代码示例来源:origin: janishar/PlaceHolderView

yStart = event.getRawY();
  y = event.getRawY();
  activePointerId = event.getPointerId(0);
  resetDone = false;
switch (event.getAction() & MotionEvent.ACTION_MASK) {
  case MotionEvent.ACTION_DOWN:
    break;
  case MotionEvent.ACTION_MOVE:
    if(!resetDone && event.findPointerIndex(activePointerId) != SwipeDecor.PRIMITIVE_NULL) {
      y = event.getRawY();
      FrameLayout.LayoutParams layoutParamsTemp = (FrameLayout.LayoutParams) v.getLayoutParams();
      layoutParamsTemp.topMargin = (int) (y - dy);

代码示例来源:origin: burhanrashid52/PhotoEditor

int action = event.getAction();
int x = (int) event.getRawX();
int y = (int) event.getRawY();
    mPrevX = event.getX();
    mPrevY = event.getY();
    mPrevRawX = event.getRawX();
    mPrevRawY = event.getRawY();
    mActivePointerId = event.getPointerId(0);
    if (deleteView != null) {

代码示例来源:origin: daimajia/AndroidSwipeLayout

@Override
public boolean onTouchEvent(MotionEvent event) {
  if (!isSwipeEnabled()) return super.onTouchEvent(event);
  int action = event.getActionMasked();
  gestureDetector.onTouchEvent(event);
  switch (action) {
    case MotionEvent.ACTION_DOWN:
      mDragHelper.processTouchEvent(event);
      sX = event.getRawX();
      sY = event.getRawY();
    case MotionEvent.ACTION_MOVE: {
      //the drag state and the direction are already judged at onInterceptTouchEvent
      checkCanDrag(event);
      if (mIsBeingDragged) {
        getParent().requestDisallowInterceptTouchEvent(true);
        mDragHelper.processTouchEvent(event);
      }
      break;
    }
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_CANCEL:
      mIsBeingDragged = false;
      mDragHelper.processTouchEvent(event);
      break;
    default://handle other action, such as ACTION_POINTER_DOWN/UP
      mDragHelper.processTouchEvent(event);
  }
  return super.onTouchEvent(event) || mIsBeingDragged || action == MotionEvent.ACTION_DOWN;
}

代码示例来源:origin: stackoverflow.com

int[] listViewCoords = new int[2];
mListView.getLocationOnScreen(listViewCoords);
int x = (int) motionEvent.getRawX() - listViewCoords[0];
int y = (int) motionEvent.getRawY() - listViewCoords[1];
View child;
for (int i = 0; i < childCount; i++) {
  mDownX = motionEvent.getRawX();
  mDownPosition = mListView.getPositionForView(mDownView);
float deltaX = motionEvent.getRawX() - mDownX;
mVelocityTracker.addMovement(motionEvent);
mVelocityTracker.computeCurrentVelocity(500); // 1000 by defaut but it was too much

代码示例来源:origin: stackoverflow.com

viewB.setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View v) {}
 });
 viewB.setOnTouchListener(new OnTouchListener() {
   @Override
   public boolean onTouch(View v, MotionEvent event) {
     int x = (int)event.getRawX();
     int y = (int)event.getRawY();
     if(event.getAction() == MotionEvent.ACTION_UP){
       if(isViewInBounds(viewA, x, y))
         viewA.dispatchTouchEvent(event);
       else if(isViewInBounds(viewB, x, y)){
         Log.d(TAG, "onTouch ViewB");
         //Here goes code to execute on onTouch ViewB
       }
     }
     // Further touch is not handled
     return false;
   }
 });

代码示例来源:origin: Bigkoo/Android-PickerView

float ratio = 0.25f;
switch (event.getAction()) {
  case MotionEvent.ACTION_DOWN:
    startTime = System.currentTimeMillis();
    cancelFuture();
    previousY = event.getRawY();
    break;
    float dy = previousY - event.getRawY();
    previousY = event.getRawY();
    totalScrollY = totalScrollY + dy;
if (!isIgnore && event.getAction() != MotionEvent.ACTION_DOWN) {
  invalidate();

代码示例来源:origin: janishar/PlaceHolderView

pointerStartingPoint.set(event.getRawX(), event.getRawY());
  pointerCurrentPoint.set(event.getRawX(), event.getRawY());
  activePointerId = event.getPointerId(0);
  resetDone = false;
switch (event.getAction() & MotionEvent.ACTION_MASK) {
  case MotionEvent.ACTION_DOWN:
    break;
  case MotionEvent.ACTION_MOVE:
    if(!resetDone && event.findPointerIndex(activePointerId) != SwipeDecor.PRIMITIVE_NULL) {
      pointerCurrentPoint.set(event.getRawX(), event.getRawY());
      FrameLayout.LayoutParams layoutParamsTemp = (FrameLayout.LayoutParams) v.getLayoutParams();
      layoutParamsTemp.topMargin = (int) (pointerCurrentPoint.y - dy);

代码示例来源:origin: GitLqr/LQRWeChat

private boolean isCancelled(View view, MotionEvent event) {
  int[] location = new int[2];
  view.getLocationOnScreen(location);
  if (event.getRawX() < location[0] || event.getRawX() > location[0] + view.getWidth()
      || event.getRawY() < location[1] - 40) {
    return true;
  }
  return false;
}

代码示例来源:origin: stackoverflow.com

int[] listViewCoords = new int[2];
getLocationOnScreen(listViewCoords);
int x = (int)event.getRawX() - listViewCoords[0];
int y = (int)event.getRawY() - listViewCoords[1];
View child;
for (int i = 0; i < childCount; i++) {

代码示例来源:origin: stackoverflow.com

viewA.setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View v) {}
 });
 viewA.setOnTouchListener(new OnTouchListener() {
   @Override
   public boolean onTouch(View v, MotionEvent event) {
     int x = (int)event.getRawX();
     int y = (int)event.getRawY();
     if(event.getAction() == MotionEvent.ACTION_UP){
       if(isViewInBounds(viewB, x, y))
         viewB.dispatchTouchEvent(event);
       else if(isViewInBounds(viewA, x, y)){
         Log.d(TAG, "onTouch ViewA");
         //Here goes code to execute on onTouch ViewA
       }
     }
     // Further touch is not handled
     return false;
   }
 });

代码示例来源:origin: scwang90/SmartRefreshLayout

onManualOperationStart();
switch (event.getAction() & ACTION_MASK) {
  case MotionEvent.ACTION_DOWN:
    mTouchY = event.getRawY();
    mRefreshKernel.moveSpinner(0, true);
    break;
  case MotionEvent.ACTION_MOVE:
    float dy = event.getRawY() - mTouchY;
    if (dy >= 0) {
      final double M = mHeaderHeight * 2;

代码示例来源:origin: janishar/PlaceHolderView

pointerStartingPoint.set(event.getRawX(), event.getRawY());
  pointerCurrentPoint.set(event.getRawX(), event.getRawY());
  activePointerId = event.getPointerId(0);
  resetDone = false;
switch (event.getAction() & MotionEvent.ACTION_MASK) {
  case MotionEvent.ACTION_DOWN:
    break;
  case MotionEvent.ACTION_MOVE:
    if (!resetDone && event.findPointerIndex(activePointerId) != SwipeDecor.PRIMITIVE_NULL) {
      pointerCurrentPoint.set(event.getRawX(), event.getRawY());
      FrameLayout.LayoutParams layoutParamsTemp = (FrameLayout.LayoutParams) v.getLayoutParams();
      layoutParamsTemp.topMargin = (int) (pointerCurrentPoint.y - dy);

代码示例来源:origin: gzu-liyujiang/AndroidPicker

private boolean isEventWithinView(MotionEvent e, View child) {
    Rect viewRect = new Rect();
    int[] childPosition = new int[2];
    child.getLocationOnScreen(childPosition);
    int left = childPosition[0];
    int right = left + child.getWidth();
    int top = childPosition[1];
    int bottom = top + child.getHeight();
    viewRect.set(left, top, right, bottom);
    return viewRect.contains((int) e.getRawX(), (int) e.getRawY());
  }
};

代码示例来源:origin: xiaojianglaile/Calendar

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
  switch (ev.getActionMasked()) {
    case MotionEvent.ACTION_DOWN:
      mDownPosition[0] = ev.getRawX();
      mDownPosition[1] = ev.getRawY();
      mGestureDetector.onTouchEvent(ev);
      break;
  }
  return super.dispatchTouchEvent(ev);
}

代码示例来源:origin: smuyyh/BookReader

@Override
  public boolean onInterceptTouchEvent(MotionEvent e) {
    int action = e.getAction();
    switch (action) {
      case MotionEvent.ACTION_DOWN:
        downX = (int) e.getRawX();
        downY = (int) e.getRawY();
        break;
      case MotionEvent.ACTION_MOVE:
        int moveY = (int) e.getRawY();
        if (Math.abs(moveY - downY) > mTouchSlop) {
          return true;
        }
    }
    return super.onInterceptTouchEvent(e);
  }
}

代码示例来源:origin: orhanobut/dialogplus

switch (event.getAction()) {
 case MotionEvent.ACTION_DOWN:
  y = event.getRawY();
  return true;
 case MotionEvent.ACTION_MOVE:

相关文章