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

x33g5p2x  于2022-01-16 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(125)

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

Button.onTouchEvent介绍

暂无

代码示例

代码示例来源: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: vipulyaara/betterHotels

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

代码示例来源:origin: dongorigin/AndroidDemo

@Override
  public boolean onTouchEvent(MotionEvent event) {
    TouchEventHelper.displayAction(event, TAG, "onTouchEvent");
    boolean result = super.onTouchEvent(event);
    Log.i(TAG, "onTouchEvent return " + result);
    return result;
  }
}

代码示例来源:origin: googlesamples/android-BatchStepSensor

@Override
public boolean onTouchEvent(MotionEvent event) {
  switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN: {
      setPressed(true);
      if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
        animate().scaleX(0.98f).scaleY(0.98f).setDuration(100)
          .setInterpolator(new DecelerateInterpolator());
      } else {
        ViewCompat.setElevation(this, 8.f);
      }
      break;
    }
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_CANCEL: {
      setPressed(false);
      if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
        animate().scaleX(1.f).scaleY(1.f).setDuration(50)
          .setInterpolator(new BounceInterpolator());
      } else {
        ViewCompat.setElevation(this, 0.f);
      }
      break;
    }
  }
  return super.onTouchEvent(event);
}

代码示例来源:origin: 18Gray/ProCamera

@Override
public boolean onTouchEvent(final MotionEvent event)
  boolean superResult = super.onTouchEvent(event);
  if (event.getActionMasked() == MotionEvent.ACTION_DOWN
      && this.isEnabled() && mHover)

代码示例来源:origin: googlesamples/android-play-places

@Override
public boolean onTouchEvent(MotionEvent event) {
  switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN: {
      setPressed(true);
      if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
        animate().scaleX(0.98f).scaleY(0.98f).setDuration(100)
          .setInterpolator(new DecelerateInterpolator());
      } else {
        ViewCompat.setElevation(this, 8.f);
      }
      break;
    }
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_CANCEL: {
      setPressed(false);
      if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
        animate().scaleX(1.f).scaleY(1.f).setDuration(50)
          .setInterpolator(new BounceInterpolator());
      } else {
        ViewCompat.setElevation(this, 0.f);
      }
      break;
    }
  }
  return super.onTouchEvent(event);
}

代码示例来源:origin: newchenxf/audiorecord

@Override
public boolean onTouchEvent(MotionEvent event) {
  PPLog.i(TAG, "onTouchEvent");
  super.onTouchEvent(event);
  if(recordAudioListener != null){
    switch (event.getAction()){
      case MotionEvent.ACTION_DOWN:
        setSelected(true);
        downPointY = event.getY();
        recordAudioListener.onFingerPress();
        startRecordAudio();
        break;
      case MotionEvent.ACTION_UP:
        setSelected(false);
        onFingerUp();
        break;
      case MotionEvent.ACTION_MOVE:
        onFingerMove(event);
        break;
      case MotionEvent.ACTION_CANCEL:
        isCanceled = true;
        onFingerUp();
        break;
      default:
        break;
    }
  }
  return true;
}

代码示例来源:origin: easemob/kefu-android-demo

if (!mReady) {
      reset();
      return super.onTouchEvent(event);
    } else if (!isRecording || mTime < 0.6) {
    break;
return super.onTouchEvent(event);

相关文章

Button类方法