android.widget.ImageView.onTouchEvent()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(189)

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

ImageView.onTouchEvent介绍

暂无

代码示例

代码示例来源:origin: hdodenhof/CircleImageView

@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(MotionEvent event) {
  return inTouchableArea(event.getX(), event.getY()) && super.onTouchEvent(event);
}

代码示例来源:origin: qiujuer/Genius-Android

@Override
public boolean onTouchEvent(MotionEvent event) {
  //return super.onTouchEvent(event);
  final boolean ret = super.onTouchEvent(event);
  // send to touch drawable
  final TouchEffectDrawable d = mTouchDrawable;
  if (ret && d != null && isEnabled()) {
    d.onTouch(event);
  }
  return ret;
}

代码示例来源:origin: qiujuer/Genius-Android

@Override
public boolean onTouchEvent(MotionEvent event) {
  //return super.onTouchEvent(event);
  final boolean ret = super.onTouchEvent(event);
  // send to touch drawable
  final TouchEffectDrawable d = mTouchDrawable;
  if (ret && d != null && isEnabled()) {
    d.onTouch(event);
  }
  return ret;
}

代码示例来源:origin: jeasonlzy/NineGridView

return super.onTouchEvent(event);

代码示例来源:origin: cymcsg/UltimateAndroid

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
  // Check for clickable state and do nothing if disabled
  if(!this.isClickable()) {
    this.isSelected = false;
    return super.onTouchEvent(event);
  }
  // Set selected state based on Motion Event
  switch(event.getAction()) {
    case MotionEvent.ACTION_DOWN:
      this.isSelected = true;
      break;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_SCROLL:
    case MotionEvent.ACTION_OUTSIDE:
    case MotionEvent.ACTION_CANCEL:
      this.isSelected = false;
      break;
  }
  // Redraw image and return super type
  this.invalidate();
  return super.dispatchTouchEvent(event);
}

代码示例来源:origin: weexteam/weex-hackernews

@Override
public boolean onTouchEvent(MotionEvent event) {
 boolean result = super.onTouchEvent(event);
 if (wxGesture != null) {
  result |= wxGesture.onTouch(this, event);
 }
 return result;
}

代码示例来源:origin: SwiftyWang/FingerColoring-Android

@Override
public boolean onTouchEvent(MotionEvent event) {
  int x = (int) event.getX();
  int y = (int) event.getY();
  switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
      //???
      //fillColorToSameArea(x, y);
  }
  return super.onTouchEvent(event);
}

代码示例来源:origin: raphaelbussa/HeaderView

@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(MotionEvent event) {
  return inTouchableArea(event.getX(), event.getY()) && super.onTouchEvent(event);
}

代码示例来源:origin: gaolhjy/enjoyshop

@Override
public boolean onTouchEvent(MotionEvent event) {
  return inTouchableArea(event.getX(), event.getY()) && super.onTouchEvent(event);
}

代码示例来源:origin: tyzlmjj/AndroidUI

@Override
  public boolean onTouchEvent(MotionEvent event) {
    
    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
      this.setColorFilter(0x99000000);
      return true;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_CANCEL:
      this.setColorFilter(null);
      break;
    }
    return super.onTouchEvent(event);
  }
}

代码示例来源:origin: FreedomZZQ/YouJoin-Android

@Override
public boolean onTouchEvent(MotionEvent event) {
  boolean retValue = mScaleGesture.onTouchEvent(event);
  retValue = mGestureDetector.onTouchEvent(event) || retValue;
  return retValue || super.onTouchEvent(event);
}

代码示例来源:origin: zxfnicholas/CameraSDK

@Override
public boolean onTouchEvent(MotionEvent event) {
  boolean retValue = mScaleGesture.onTouchEvent(event);
  retValue = mGestureDetector.onTouchEvent(event) || retValue;
  return retValue || super.onTouchEvent(event);
}

代码示例来源:origin: devunwired/custom-touch-examples

@Override
  public boolean onTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
      // We don't care about this event directly, but we declare
      // interest so we can get later multi-touch events.
      return true;
    }

    switch (event.getPointerCount()) {
      case 3:
        // With three fingers down, zoom the image
        // using the ScaleGestureDetector
        return mScaleDetector.onTouchEvent(event);
      case 2:
        // With two fingers down, rotate the image
        // following the fingers
        return doRotationEvent(event);
      default:
        //Ignore this event
        return super.onTouchEvent(event);
    }
  }
}

代码示例来源:origin: LukeMee/NineGridlayout

@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);
}

代码示例来源:origin: huangfangyi/FanXin

/**
 * monitor if touched
 *
 * @param event
 * @return
 */
@Override
public boolean onTouchEvent(MotionEvent event) {
  switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
      pressPaint.setAlpha(pressAlpha);
      invalidate();
      break;
    case MotionEvent.ACTION_UP:
      pressPaint.setAlpha(0);
      invalidate();
      break;
    case MotionEvent.ACTION_MOVE:
      break;
    default:
      pressPaint.setAlpha(0);
      invalidate();
      break;
  }
  return super.onTouchEvent(event);
}

代码示例来源:origin: HMY314/NineGridLayout

@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);
}

代码示例来源:origin: qintong91/InsLoadingAnimation

@Override
public boolean onTouchEvent(MotionEvent event) {
  boolean result = false;
  if (DEBUG) {
    Log.d(TAG, "onTouchEvent: " + event.getAction());
  }
  switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN: {
      startDownAnim();
      result = true;
      break;
    }
    case MotionEvent.ACTION_UP: {
      startUpAnim();
      break;
    }
    case MotionEvent.ACTION_CANCEL: {
      startUpAnim();
      break;
    }
  }
  return super.onTouchEvent(event) || result;
}

代码示例来源:origin: FreedomZZQ/YouJoin-Android

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
  // Check for clickable state and do nothing if disabled
  if (!this.isClickable()) {
    this.isSelected = false;
    return super.onTouchEvent(event);
  }
  // Set selected state based on Motion Event
  switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
      this.isSelected = true;
      break;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_SCROLL:
    case MotionEvent.ACTION_OUTSIDE:
    case MotionEvent.ACTION_CANCEL:
      this.isSelected = false;
      break;
  }
  // Redraw image and return super type
  this.invalidate();
  return super.dispatchTouchEvent(event);
}

代码示例来源:origin: RameshBhupathi/CollapsingToolbar-With-Webview

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
  // Check for clickable state and do nothing if disabled
  if (!this.isClickable()) {
    this.isSelected = false;
    return super.onTouchEvent(event);
  }
  // Set selected state based on Motion Event
  switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
      this.isSelected = true;
      break;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_SCROLL:
    case MotionEvent.ACTION_OUTSIDE:
    case MotionEvent.ACTION_CANCEL:
      this.isSelected = false;
      break;
  }
  // Redraw image and return super type
  this.invalidate();
  return super.dispatchTouchEvent(event);
}

代码示例来源:origin: 452896915/SnapShotMonitor

@Override
public boolean onTouchEvent(MotionEvent event) {
  float xPos = event.getX();
  float yPos = event.getY();
  switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
      currentLine = new LineInfo(currentLineType);
      currentLine.addPoint(new PointInfo(xPos, yPos));
      lineList.add(currentLine);
      invalidate();
      return true; // return true消费掉ACTION_DOWN事件,否则不会触发ACTION_UP
    case MotionEvent.ACTION_MOVE:
      currentLine.addPoint(new PointInfo(xPos, yPos));
      invalidate();
      return true;
    case MotionEvent.ACTION_UP:
      currentLine.addPoint(new PointInfo(xPos, yPos));
      invalidate();
      break;
  }
  return super.onTouchEvent(event);
}

相关文章

ImageView类方法