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

x33g5p2x  于2022-01-29 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(165)

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

TextView.onTouchEvent介绍

暂无

代码示例

代码示例来源:origin: Clans/FloatingActionButton

@Override
public boolean onTouchEvent(MotionEvent event) {
  if (mFab == null || mFab.getOnClickListener() == null || !mFab.isEnabled()) {
    return super.onTouchEvent(event);
  }
  int action = event.getAction();
  switch (action) {
    case MotionEvent.ACTION_UP:
      onActionUp();
      mFab.onActionUp();
      break;
    case MotionEvent.ACTION_CANCEL:
      onActionUp();
      mFab.onActionUp();
      break;
  }
  mGestureDetector.onTouchEvent(event);
  return super.onTouchEvent(event);
}

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

if (mState == STATE_INPUT) {
  return super.onTouchEvent(event);
return super.onTouchEvent(event);

代码示例来源:origin: mayubao/KuaiChuan

/**
   * 重写TextView 让其有按下的效果
   * @param event
   * @return
   */
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()){
      case MotionEvent.ACTION_DOWN:{
        break;
      }case MotionEvent.ACTION_UP:{
        break;
      }
    }

    return super.onTouchEvent(event);
  }
}

代码示例来源:origin: adgvcxz/Dribbble-MVVM

@Override
public boolean onTouchEvent(MotionEvent event) {
  linkHit = false;
  boolean res = super.onTouchEvent(event);
  if (dontConsumeNonUrlClicks)
    return linkHit;
  return res;
}

代码示例来源:origin: huangweicai/OkLibDemo

@Override
public boolean onTouchEvent(MotionEvent event) {
  if (adjuster != null) {
    if (adjuster.onTouch(this, event) && isAutoAdjust()) {
      super.onTouchEvent(event);
      return true;
    }
  }
  return super.onTouchEvent(event);
}

代码示例来源:origin: RuffianZhong/RWidgetHelper

@Override
public boolean onTouchEvent(MotionEvent event) {
  if (mHelper != null) {
    mHelper.onTouchEvent(event);
  }
  return super.onTouchEvent(event);
}

代码示例来源:origin: nomanr/ZoomTextView

@Override
public boolean onTouchEvent(@NonNull MotionEvent ev) {
  super.onTouchEvent(ev);
  mScaleDetector.onTouchEvent(ev);
  return true;
}

代码示例来源:origin: mabeijianxi/ViewLargerImageUtil

@Override
public boolean onTouchEvent(MotionEvent event) {
  boolean superResult = super.onTouchEvent(event);
  return mDetector.onTouchEvent(event, superResult);
}

代码示例来源:origin: ASCE1885/AdvancedAndroidExample

@Override
public boolean onTouchEvent(MotionEvent event) {
  switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
      Log.e(TAG, "onTouchEvent ACTION_DOWN");
      break;
    case MotionEvent.ACTION_MOVE:
      Log.e(TAG, "onTouchEvent ACTION_MOVE");
      break;
    case MotionEvent.ACTION_UP:
      Log.e(TAG, "onTouchEvent ACTION_UP");
      break;
    case MotionEvent.ACTION_CANCEL:
      Log.e(TAG, "onTouchEvent ACTION_CANCEL");
      break;
    default:
      break;
  }
  return super.onTouchEvent(event);
}

代码示例来源:origin: douzifly/clear-todolist

@Override
public boolean onTouchEvent(MotionEvent event) {
  if (mFab == null || mFab.getOnClickListener() == null || !mFab.isEnabled()) {
    return super.onTouchEvent(event);
  }
  int action = event.getAction();
  switch (action) {
    case MotionEvent.ACTION_UP:
      onActionUp();
      mFab.onActionUp();
      break;
  }
  mGestureDetector.onTouchEvent(event);
  return super.onTouchEvent(event);
}

代码示例来源:origin: yaozs/YzsLib

@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
  if (event.getAction() == MotionEvent.ACTION_UP) {
    if (!popupWindow.isShowing()) {
      showDropDown();
    } else {
      dismissDropDown();
    }
  }
  return super.onTouchEvent(event);
}

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

final View rt = findViewById(R.id.rlt_touch);
final TextView tv = (TextView) findViewById(R.id.description);

rt.setOnTouchListener(new OnTouchListener() {
  final Rect r = new Rect();
  final Point p1 = new Point();
  final Point p2 = new Point();

  @Override
  public boolean onTouch(View v, MotionEvent event) {
    Log.d("test", "clicked!");

    if (gestureDetector.onTouchEvent(event)) {
      Log.d("test", "gesture detected");
    }

    // offset touch location into the TextView and forward it if relevant
    rt.getGlobalVisibleRect(r, p2);
    tv.getGlobalVisibleRect(r, p1);
    event.offsetLocation(p2.x - p1.x, p2.y - p1.y);
    if (r.contains((int) event.getRawX(), (int) event.getRawY())) {
      tv.onTouchEvent(event);
    }

    return true;
  }
});

代码示例来源:origin: jaredrummler/MaterialSpinner

@Override public boolean onTouchEvent(@NonNull MotionEvent event) {
 if (event.getAction() == MotionEvent.ACTION_UP) {
  if (isEnabled() && isClickable()) {
   if (!popupWindow.isShowing()) {
    expand();
   } else {
    collapse();
   }
  }
 }
 return super.onTouchEvent(event);
}

代码示例来源:origin: Blankeer/MDWechat

@Override
public boolean onTouchEvent(MotionEvent event) {
  if (mFab == null || mFab.getOnClickListener() == null || !mFab.isEnabled()) {
    return super.onTouchEvent(event);
  }
  int action = event.getAction();
  switch (action) {
    case MotionEvent.ACTION_UP:
      onActionUp();
      mFab.onActionUp();
      break;
    case MotionEvent.ACTION_CANCEL:
      onActionUp();
      mFab.onActionUp();
      break;
  }
  mGestureDetector.onTouchEvent(event);
  return super.onTouchEvent(event);
}

代码示例来源:origin: PrivacyApps/document-viewer

@Override
public boolean onTouchEvent(final MotionEvent event) {
  if (LCTX.isDebugEnabled()) {
    LCTX.d("onTouch(" + event + ")");
  }
  super.onTouchEvent(event);
  return detector.onTouchEvent(event);
}

代码示例来源:origin: RuffianZhong/RTextView

return super.onTouchEvent(event);

代码示例来源:origin: BoBoMEe/Android-Demos

@Override
public boolean onTouchEvent(MotionEvent event) {
  // 在event为actionDown时标记用户点击是否在相应的图片范围内
  if (event.getAction() == MotionEvent.ACTION_DOWN) {
    resetTouchStatus();
    if (mDrawableClickListener != null) {
      mIsLeftTouched = touchLeftDrawable(event);
      mIsTopTouched = touchTopDrawable(event);
      mIsRightTouched = touchRightDrawable(event);
      mIsBottomTouched = touchBottomDrawable(event);
    }
  }
  return super.onTouchEvent(event);
}

代码示例来源:origin: AlexLiuSheng/AnimSideBar

@Override
public boolean onTouchEvent(MotionEvent event) {
  switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
    case MotionEvent.ACTION_MOVE:
      if(event.getX()>(w-getPaddingRight()-singleTextH-10)) {
        eventY = event.getY();
        invalidate();
        return true;
      }else{
        eventY = 0;
        invalidate();
        break;
      }
    case MotionEvent.ACTION_CANCEL:
      eventY = 0;
      invalidate();
      return true;
    case MotionEvent.ACTION_UP:
      if(event.getX()>(w-getPaddingRight()-singleTextH-10)) {
        eventY = 0;
        invalidate();
        return true;
      }else
        break;
  }
  return super.onTouchEvent(event);
}

代码示例来源:origin: WeAreFairphone/FP2-Launcher

boolean result = super.onTouchEvent(event);

代码示例来源:origin: wangxp423/ViewExercise

@Override
  public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        LogUtils.d("Test", "ACTION_DOWN");
//                return true;
        break;
      case MotionEvent.ACTION_MOVE:
        LogUtils.d("Test", "ACTION_MOVE");
        break;
      case MotionEvent.ACTION_UP:
        LogUtils.d("Test", "ACTION_UP");
//                return true;
        break;
      case MotionEvent.ACTION_CANCEL:
        LogUtils.d("Test", "ACTION_CANCEL");
        break;
      default:
        LogUtils.d("Test", "default");
        break;
    }
    return super.onTouchEvent(event);
//        return false;
//        return true;
  }
}

相关文章

TextView类方法