本文整理了Java中android.view.MotionEvent.getY()
方法的一些代码示例,展示了MotionEvent.getY()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MotionEvent.getY()
方法的具体详情如下:
包路径:android.view.MotionEvent
类名称:MotionEvent
方法名:getY
暂无
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Determines the center point between two pointer touch points.
*
* @param point
* @param event
*/
private static void midPoint(MPPointF point, MotionEvent event) {
float x = event.getX(0) + event.getX(1);
float y = event.getY(0) + event.getY(1);
point.x = (x / 2f);
point.y = (y / 2f);
}
代码示例来源:origin: stackoverflow.com
@Override
public boolean onTouchEvent(MotionEvent event) {
int x = (int)event.getX();
int y = (int)event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE:
case MotionEvent.ACTION_UP:
}
return false;
}
代码示例来源:origin: facebook/litho
@Override
public boolean shouldHandleTouchEvent(MotionEvent event) {
return Build.VERSION.SDK_INT >= LOLLIPOP &&
mDrawable != null &&
mDrawable instanceof RippleDrawable &&
event.getActionMasked() == MotionEvent.ACTION_DOWN &&
getBounds().contains((int) event.getX(), (int) event.getY());
}
}
代码示例来源:origin: stackoverflow.com
private final Paint mPaint = new Paint();
private final Point mSize = new Point();
private final Point mStartPosition = new Point();
if(!mRegion.contains((int)event.getX(), (int)event.getY()))
if(event.getAction() == MotionEvent.ACTION_DOWN)
mStartPosition.x = (int)event.getX();
mStartPosition.y = (int)event.getY();
bringToFront();
onSelected();
return true;
else if(event.getAction() == MotionEvent.ACTION_MOVE)
x = (int)event.getX() - mStartPosition.x;
y = (int)event.getY() - mStartPosition.y;
mStartPosition.x = (int)event.getX();
mStartPosition.y = (int)event.getY();
代码示例来源:origin: stackoverflow.com
mCirclePaint = new Paint();
mCirclePaint.setColor(Color.BLUE);
mCirclePaint.setStrokeWidth(40);
mCirclePaint.setStyle(Paint.Style.FILL);
xTouch = (int) event.getX(0);
yTouch = (int) event.getY(0);
xTouch = (int) event.getX(actionIndex);
yTouch = (int) event.getY(actionIndex);
xTouch = (int) event.getX(actionIndex);
yTouch = (int) event.getY(actionIndex);
代码示例来源:origin: stackoverflow.com
pTouch.setColor(Color.TRANSPARENT);
pTouch.setMaskFilter(new BlurMaskFilter(15, Blur.NORMAL));
public boolean onTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
X = (int) ev.getX();
Y = (int) ev.getY();
invalidate();
X = (int) ev.getX();
Y = (int) ev.getY();
invalidate();
break;
代码示例来源:origin: stackoverflow.com
public boolean onTouch(View view, MotionEvent event) {
if(event.getAction() != MotionEvent.ACTION_UP){
Point point = new Point();
point.x = event.getX();
point.y = event.getY();
points.add(point);
invalidate();
Log.d(TAG, "point: " + point);
return true;
}
return super.onTouchEvent(event);
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* returns the distance between two pointer touch points
*
* @param event
* @return
*/
private static float spacing(MotionEvent event) {
float x = event.getX(0) - event.getX(1);
float y = event.getY(0) - event.getY(1);
return (float) Math.sqrt(x * x + y * y);
}
代码示例来源:origin: facebook/litho
private boolean shouldHandleTextOffsetOnTouch(MotionEvent event) {
return mTextOffsetOnTouchListener != null
&& event.getActionMasked() == ACTION_DOWN
&& getBounds().contains((int) event.getX(), (int) event.getY());
}
代码示例来源:origin: stackoverflow.com
dv = new DrawingView(this);
setContentView(dv);
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setDither(true);
mPaint.setColor(Color.GREEN);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(12);
mPath = new Path();
mBitmapPaint = new Paint(Paint.DITHER_FLAG);
circlePaint = new Paint();
circlePath = new Path();
circlePaint.setAntiAlias(true);
circlePaint.setColor(Color.BLUE);
circlePaint.setStyle(Paint.Style.STROKE);
circlePaint.setStrokeJoin(Paint.Join.MITER);
circlePaint.setStrokeWidth(4f);
float x = event.getX();
float y = event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
touch_start(x, y);
代码示例来源:origin: stackoverflow.com
imageView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN){
textView.setText("Touch coordinates : " +
String.valueOf(event.getX()) + "x" + String.valueOf(event.getY()));
}
return true;
}
});
代码示例来源:origin: PhilJay/MPAndroidChart
@Override
public void onChartGestureStart(MotionEvent me, ChartTouchListener.ChartGesture lastPerformedGesture) {
Log.i("Gesture", "START, x: " + me.getX() + ", y: " + me.getY());
}
代码示例来源:origin: rey5137/material
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
int action = event.getActionMasked();
if(action == MotionEvent.ACTION_DOWN && ! mBackground.isPointerOver(event.getX(), event.getY()))
return false;
boolean result = super.onTouchEvent(event);
return getRippleManager().onTouchEvent(this, event) || result;
}
代码示例来源:origin: stackoverflow.com
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setDither(true);
mPaint.setColor(0xFFFF0000);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(20);
mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 },
0.4f, 6, 3.5f);
mPaint.setColor(color);
float x = event.getX();
float y = event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
touch_start(x, y);
代码示例来源:origin: stackoverflow.com
public boolean onTouchEvent(MotionEvent event){
int action = event.getAction();
int x = event.getX() // or getRawX();
int y = event.getY();
switch(action){
case MotionEvent.ACTION_DOWN:
if (x >= xOfYourBitmap && x < (xOfYourBitmap + yourBitmap.getWidth())
&& y >= yOfYourBitmap && y < (yOfYourBitmap + yourBitmap.getHeight())) {
//tada, if this is true, you've started your click inside your bitmap
}
break;
}
}
代码示例来源:origin: google/ExoPlayer
@Override
public boolean onDown(MotionEvent e) {
// Initialize drag gesture.
previousTouchPointPx.set(e.getX(), e.getY());
return true;
}
代码示例来源:origin: k9mail/k-9
@Override
public boolean onTouchEvent(MotionEvent event) {
// Convert coordinates to our internal coordinate system
float x = event.getX() - mTranslationOffset;
float y = event.getY() - mTranslationOffset;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// Check whether the user pressed on (or near) the pointer
float[] pointerPosition = calculatePointerPosition(mAngle);
if (x >= (pointerPosition[0] - 48) && x <= (pointerPosition[0] + 48)
&& y >= (pointerPosition[1] - 48) && y <= (pointerPosition[1] + 48)) {
mUserIsMovingPointer = true;
invalidate();
}
break;
case MotionEvent.ACTION_MOVE:
if (mUserIsMovingPointer) {
mAngle = (float) java.lang.Math.atan2(y, x);
mPointerColor.setColor(calculateColor(mAngle));
invalidate();
}
break;
case MotionEvent.ACTION_UP:
mUserIsMovingPointer = false;
break;
}
return true;
}
代码示例来源:origin: stackoverflow.com
public class VerticalScrollView extends ScrollView {
private float xDistance, yDistance, lastX, lastY;
public VerticalScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
xDistance = yDistance = 0f;
lastX = ev.getX();
lastY = ev.getY();
break;
case MotionEvent.ACTION_MOVE:
final float curX = ev.getX();
final float curY = ev.getY();
xDistance += Math.abs(curX - lastX);
yDistance += Math.abs(curY - lastY);
lastX = curX;
lastY = curY;
if(xDistance > yDistance)
return false;
}
return super.onInterceptTouchEvent(ev);
}
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Saves the current Matrix state and the touch-start point.
*
* @param event
*/
private void saveTouchStart(MotionEvent event) {
mSavedMatrix.set(mMatrix);
mTouchStartPoint.x = event.getX();
mTouchStartPoint.y = event.getY();
mClosestDataSetToTouch = mChart.getDataSetByTouchPoint(event.getX(), event.getY());
}
代码示例来源:origin: stackoverflow.com
private Paint paint = new Paint();
private float endRadius = 0;
private float rippleX = 0;
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.WHITE);
paint.setAntiAlias(true);
public boolean onTouchEvent(@NonNull MotionEvent event)
rippleX = event.getX();
rippleY = event.getY();
switch(event.getAction())
内容来源于网络,如有侵权,请联系作者删除!