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

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

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

MotionEvent.transform介绍

暂无

代码示例

代码示例来源:origin: alexvasilkov/GestureViews

private static void transformToPagerEvent(MotionEvent event, View view, ViewPager pager) {
  tmpMatrix.reset();
  transformMatrixToPager(tmpMatrix, view, pager);
  event.transform(tmpMatrix);
}

代码示例来源:origin: robolectric/robolectric

event.transform(matrix);

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

@Override
 public boolean onTouchEvent(MotionEvent event) {
   event.transform(invertMatrix);

代码示例来源:origin: GcsSloop/ViewSupport

@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
private static MotionEvent transformEventNew(MotionEvent e, Matrix m) {
  MotionEvent newEvent = MotionEvent.obtain(e);
  newEvent.transform(m);
  return newEvent;
}

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

@Override
public boolean onTouchEvent(MotionEvent event) {
  //anything happening with event here is the X Y of the raw screen event.

  event.offsetLocation(event.getRawX()-event.getX(),event.getRawY()-event.getY()); //converts the event.getX() to event.getRaw() so the title bar doesn't fubar.

  //anything happening with event here is the X Y of the raw screen event, relative to the view.
  if (rawTouch(this,event)) return true;

  if (invertMatrix != null) event.transform(invertMatrix);
  //anything happening with event now deals with the scene space.

  return touch(this,event);
}

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

private final Matrix mMatrix = new Matrix();

@Override
public boolean onTouchEvent(MotionEvent event) {
  if (event.getPointerCount() == 2) {
    float scale = (float) Math.sqrt(getScaleX());
    float focalX = (event.getX(0) + event.getX(1)) / 2;
    float focalY = (event.getY(0) + event.getY(1)) / 2;
    mMatrix.setScale(scale, scale, focalX, focalY);
    event.transform(mMatrix);
    return mScaleGestureDetector.onTouchEvent(event);
  } 
  return false;
}

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

@Override
 public boolean onTouchEvent(MotionEvent event) {
   Matrix matrix = new Matrix();
   matrix.setScale(1, 0);
   event.transform(matrix);
   return super.onTouchEvent(event);
 }

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

@Override
protected void dispatchDraw(Canvas canvas) {
  Log.d(TAG, "dispatchDraw " + canvas);
  canvas.save();
  canvas.concat(mMatrix);
  super.dispatchDraw(canvas);
  canvas.restore();       
}

@Override   
public boolean dispatchTouchEvent(MotionEvent ev) {
  Log.d(TAG, "dispatchTouchEvent " + ev);
  ev.transform(getInvMatrix()); // 
  return super.dispatchTouchEvent(ev);

}

private Matrix getInvMatrix()
{
  if(!mTmpMatIsInvMat)
    mMatrix.invert(mTmpMat);
  mTmpMatIsInvMat = true;
  return mTmpMat;
}

代码示例来源:origin: mapsforge/mapsforge

private MotionEvent rotateEvent(final MotionEvent event, float degrees, float px, float py) {
  if (degrees == 0)
    return event;
  matrix.setRotate(degrees, px, py);
  final MotionEvent rotatedEvent;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    rotatedEvent = MotionEvent.obtain(event);
    rotatedEvent.transform(matrix);
  } else {
    rotatedEvent = MotionEvent.obtainNoHistory(event);
    points[0] = event.getX();
    points[1] = event.getY();
    matrix.mapPoints(points);
    rotatedEvent.setLocation(points[0], points[1]);
  }
  return rotatedEvent;
}

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

recycler.setOnTouchListener(new View.OnTouchListener() {
   @Override
   public boolean onTouch(View v, MotionEvent event) {
     MotionEvent e = MotionEvent.obtain(event);
     Matrix m = new Matrix();
     m.setTranslate(0f, -backgroundTranslation);
     e.transform(m);
     background.dispatchTouchEvent(e);
     e.recycle();
     return false;
   }
 });

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

event.transform(invertMatrix);
switch (event.getAction()) {
  case MotionEvent.ACTION_DOWN:

代码示例来源:origin: 1993hzw/Doodle

@Override
  public boolean dispatchTouchEvent(MotionEvent event) {
    if (mOnTouchListener != null) {
      if (mOnTouchListener.onTouch(this, event)) {
        return true;
      }
    }
    mTouchX = event.getX();
    mTouchY = event.getY();

    // 把事件转发给innerView,避免在区域外不可点击
    MotionEvent transformedEvent = MotionEvent.obtain(event);
//        final float offsetX = mInner.getScrollX() - mInner.getLeft();
//        final float offsetY = mInner.getScrollY() - mInner.getTop();
//        transformedEvent.offsetLocation(offsetX, offsetY);
    mTouchEventMatrix.reset();
    mTouchEventMatrix.setRotate(-mDoodleRotateDegree, getWidth() / 2, getHeight() / 2);
    transformedEvent.transform(mTouchEventMatrix);
    boolean handled = mInner.onTouchEvent(transformedEvent);
    transformedEvent.recycle();

    return handled;
  }

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

ev2.transform(m);
if(child.dispatchTouchEvent(ev2)) {
  return true;

相关文章