本文整理汇总了Java中android.view.MotionEvent.getY方法的典型用法代码示例。如果您正苦于以下问题:Java MotionEvent.getY方法的具体用法?Java MotionEvent.getY怎么用?Java MotionEvent.getY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.MotionEvent
的用法示例。
在下文中一共展示了MotionEvent.getY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onControllerTouchEvent
import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onControllerTouchEvent(MotionEvent ev) {
int action = ev.getAction();
int x = (int) ev.getX();
int y = (int) ev.getY();
switch (action) {
case MotionEvent.ACTION_DOWN:
return handleTouchDown(ev);
case MotionEvent.ACTION_MOVE:
visualizeResizeForDelta(x - mXDown, y - mYDown);
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
visualizeResizeForDelta(x - mXDown, y - mYDown);
onTouchUp();
mXDown = mYDown = 0;
break;
}
return true;
}
示例2: onTouchEvent
import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
float x = event.getX() - mPadding;
float y = event.getY() - mPadding;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// Reject touches in the padding region
if (x < 0 || y < 0 || x > mWidth + mInset * 2 || y > mHeight + mInset * 2) {
return false;
}
case MotionEvent.ACTION_MOVE:
setSaturation(getSaturationForX(x - mInset));
setValue(getValueForY(y - mInset));
break;
}
return true;
}
示例3: onTouchEvent
import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
float x = event.getX();
float y = event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: //按下
setDefault();
handleDown(x, y);
return true;
case MotionEvent.ACTION_UP: //弹起
type = 1;//弹起刷新
invalidate();//刷新界面
//一次按下结束,返回点击的数字
if (onNumberClickListener != null) {
if (number != null) {
if (number.equals("delete")) {
onNumberClickListener.onNumberDelete();
} else {
onNumberClickListener.onNumberReturn(number);
}
}
}
//恢复默认
setDefault();
return true;
case MotionEvent.ACTION_CANCEL: //取消
//恢复默认值
setDefault();
return true;
}
return false;
}
示例4: onTouchDown
import android.view.MotionEvent; //导入方法依赖的package包/类
private void onTouchDown(MotionEvent ev) {
onTouchUp();
downY = ev.getY() + 0.5f;
lastX = downX = ev.getX() + 0.5f;
mStartScrollY = getScrollY();
mOverScroller.abortAnimation();
isFling = false;
if (isFloat()) {
if (mFloatView.getMeasuredHeight() + floatTopOffset > downY) {
inTopTouch = true;
} else {
inTopTouch = false;
}
} else {
if (topHeight - mStartScrollY > downY) {
inTopTouch = true;
} else {
inTopTouch = false;
}
}
isFirst = true;
initScrollTarget();
}
示例5: onTouch
import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onTouch(View v, MotionEvent event) {
mTouchX = event.getX();
mTouchY = event.getY();
if (mShown) {
mQuickActionViewLayout.onTouchEvent(event);
}
return mShown;
}
示例6: onTouchEvent
import android.view.MotionEvent; //导入方法依赖的package包/类
/**
* Used to trigger the scale animation that takes places on the
* icon when the button is touched.
*
* @param event
* @return
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isEnabled)
return true;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
/*
Commented out this line and moved the animation effect to the action up event due to
conflicts that were occurring when library is used in sliding type views.
icon.animate().scaleX(0.7f).scaleY(0.7f).setDuration(150).setInterpolator(DECCELERATE_INTERPOLATOR);
*/
setPressed(true);
break;
case MotionEvent.ACTION_MOVE:
float x = event.getX();
float y = event.getY();
boolean isInside = (x > 0 && x < getWidth() && y > 0 && y < getHeight());
if (isPressed() != isInside) {
setPressed(isInside);
}
break;
case MotionEvent.ACTION_UP:
icon.animate().scaleX(0.7f).scaleY(0.7f).setDuration(150).setInterpolator(DECCELERATE_INTERPOLATOR);
icon.animate().scaleX(1).scaleY(1).setInterpolator(DECCELERATE_INTERPOLATOR);
if (isPressed()) {
performClick();
setPressed(false);
}
break;
case MotionEvent.ACTION_CANCEL:
setPressed(false);
break;
}
return true;
}
示例7: onTouchEvent
import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
float x = event.getX();
float y = event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
if (mTouchable) {
mDownX = x;
mDownY = y;
return true;
}
break;
case MotionEvent.ACTION_UP:
if (mCircleClickListener != null) {
if (Math.abs(x - mDownX) <= mTouchSlop && Math.abs(y - mDownY) <= mTouchSlop) {
float max = Float.MAX_VALUE;
int index = 0;
for (int i = 0; i < mCirclePoints.size(); i++) {
PointF pointF = mCirclePoints.get(i);
float offset = Math.abs(pointF.x - x);
if (offset < max) {
max = offset;
index = i;
}
}
mCircleClickListener.onClick(index);
}
}
break;
default:
break;
}
return super.onTouchEvent(event);
}
示例8: determineScrollingStart
import android.view.MotionEvent; //导入方法依赖的package包/类
protected void determineScrollingStart(MotionEvent ev, float touchSlopScale) {
// Disallow scrolling if we don't have a valid pointer index
final int pointerIndex = ev.findPointerIndex(mActivePointerId);
if (pointerIndex == -1) return;
// Disallow scrolling if we started the gesture from outside the viewport
final float x = ev.getX(pointerIndex);
final float y = ev.getY(pointerIndex);
if (!isTouchPointInViewportWithBuffer((int) x, (int) y)) return;
final int xDiff = (int) Math.abs(x - mLastMotionX);
final int touchSlop = Math.round(touchSlopScale * mTouchSlop);
boolean xMoved = xDiff > touchSlop;
if (xMoved) {
// Scroll if the user moved far enough along the X axis
mTouchState = TOUCH_STATE_SCROLLING;
mTotalMotionX += Math.abs(mLastMotionX - x);
mLastMotionX = x;
mLastMotionXRemainder = 0;
onScrollInteractionBegin();
pageBeginMoving();
// Stop listening for things like pinches.
requestDisallowInterceptTouchEvent(true);
}
}
示例9: getSpan
import android.view.MotionEvent; //导入方法依赖的package包/类
double getSpan(MotionEvent event) {
int P = event.getPointerCount();
if (P < 2) return 0;
final double x0 = event.getX(0); // + zero[0];
final double x1 = event.getX(1); // + zero[0];
final double y0 = event.getY(0); // + zero[1];
final double y1 = event.getY(1); // + zero[1];
final double span = Math.hypot(x1 - x0, y1 - y0);
return span;
}
示例10: onDoubleTap
import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onDoubleTap(MotionEvent e) {
boolean consumed = false;
if (doubleTapListener != null) {
consumed = doubleTapListener.onDoubleTap(e);
}
if (state == State.NONE) {
float targetZoom = (normalizedScale == minScale) ? maxScale : minScale;
DoubleTapZoom doubleTap = new DoubleTapZoom(targetZoom, e.getX(), e.getY(), false);
compatPostOnAnimation(doubleTap);
consumed = true;
}
return consumed;
}
示例11: onTouchEvent
import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
//是否可滑动
if (!isScroll) {
return false;
}
if (mVelocityTracker == null) {
mVelocityTracker = VelocityTracker.obtain();
}
mVelocityTracker.addMovement(event);
final int action = event.getAction();
final float x = event.getX();
final float y = event.getY();
switch (action) {
case MotionEvent.ACTION_DOWN:
//Log.e(TAG, "event down!");
if (!mScroller.isFinished()) {
mScroller.abortAnimation();
}
mLastMotionX = x;
//---------------New Tree----------------------
mLastMotionY = y;
//---------------------------------------------
break;
case MotionEvent.ACTION_MOVE:
int deltaX = (int) (mLastMotionX - x);
//---------------New Tree----------------------
int deltaY = (int) (mLastMotionY - y);
if (Math.abs(deltaX) < 200 && Math.abs(deltaY) > 10)
break;
mLastMotionY = y;
//-------------------------------------
mLastMotionX = x;
scrollBy(deltaX, 0);
break;
case MotionEvent.ACTION_UP:
//Log.e(TAG, "event : up");
// if (mTouchState == TOUCH_STATE_SCROLLING) {
final VelocityTracker velocityTracker = mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000);
int velocityX = (int) velocityTracker.getXVelocity();
//Log.e(TAG, "velocityX:" + velocityX);
if (velocityX > SNAP_VELOCITY && mCurScreen > 0) {
// Fling enough to move left
//Log.e(TAG, "snap left");
snapToScreen(mCurScreen - 1);
} else if (velocityX < -SNAP_VELOCITY
&& mCurScreen < getChildCount() - 1) {
// Fling enough to move right
//Log.e(TAG, "snap right");
snapToScreen(mCurScreen + 1);
} else {
snapToDestination();
}
if (mVelocityTracker != null) {
mVelocityTracker.recycle();
mVelocityTracker = null;
}
// }
mTouchState = TOUCH_STATE_REST;
break;
case MotionEvent.ACTION_CANCEL:
mTouchState = TOUCH_STATE_REST;
break;
}
return true;
}
示例12: onTouchEvent
import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
int action = MotionEventCompat.getActionMasked(event);
//L.e("call: onTouchEvent([event])-> " + action + " " + mDownScrollY);
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
int count = event.getPointerCount();
if (count == 1) {
isTouchDown = false;
}
handleTouchUp();
} else if (action == MotionEvent.ACTION_MOVE) {
float y = event.getY();
float dy = lastY - y;
isTouchDown = true;
if (order == NONE) {
if (dy > 0) {
order = BOTTOM;
} else {
order = TOP;
}
}
if (Math.abs(dy) > mTouchSlop) {
int scrollY = getScrollY();
int needScrollerY = (int) (dy * (1 - 0.4 - Math.abs(scrollY) * 1.f / getMeasuredHeight()));
if (mDownScrollY != 0) {
if (mDownScrollY < 0 && (scrollY + needScrollerY) > 0) {
needScrollerY = -scrollY;
} else if (mDownScrollY > 0 && (scrollY + needScrollerY) < 0) {
needScrollerY = -scrollY;
}
}
scrollBy(0, needScrollerY);
lastY = y;
if (mCurState == NORMAL /*|| mCurState == FINISH*/) {
mCurState = MOVE;
}
}
} else if (action == MotionEvent.ACTION_POINTER_DOWN) {
//多个手指按下
lastY = event.getY();
} else if (action == MotionEvent.ACTION_DOWN) {
handleTouchDown(event);
}
return true;
}
示例13: handleTouchEvent
import android.view.MotionEvent; //导入方法依赖的package包/类
/**
* Handles the touch event and determines whether to show the fast scroller (or updates it if
* it is already showing).
*/
public void handleTouchEvent(MotionEvent ev, int downX, int downY, int lastY) {
ViewConfiguration config = ViewConfiguration.get(mRv.getContext());
int action = ev.getAction();
int y = (int) ev.getY();
switch (action) {
case MotionEvent.ACTION_DOWN:
if (isNearThumb(downX, downY)) {
mTouchOffset = downY - mThumbOffset.y;
}
break;
case MotionEvent.ACTION_MOVE:
// Check if we should start scrolling, but ignore this fastscroll gesture if we have
// exceeded some fixed movement
mIgnoreDragGesture |= Math.abs(y - downY) > config.getScaledPagingTouchSlop();
if (!mIsDragging && !mIgnoreDragGesture && mRv.supportsFastScrolling() &&
isNearThumb(downX, lastY) &&
Math.abs(y - downY) > config.getScaledTouchSlop()) {
mRv.getParent().requestDisallowInterceptTouchEvent(true);
mIsDragging = true;
if (mCanThumbDetach) {
mIsThumbDetached = true;
}
mTouchOffset += (lastY - downY);
mPopup.animateVisibility(true);
showActiveScrollbar(true);
}
if (mIsDragging) {
// Update the fastscroller section name at this touch position
int top = mRv.getBackgroundPadding().top;
int bottom = top + mRv.getVisibleHeight() - mThumbHeight;
float boundedY = (float) Math.max(top, Math.min(bottom, y - mTouchOffset));
String sectionName = mRv.scrollToPositionAtProgress((boundedY - top) /
(bottom - top));
mPopup.setSectionName(sectionName);
mPopup.animateVisibility(!sectionName.isEmpty());
mRv.invalidate(mPopup.updateFastScrollerBounds(lastY));
mLastTouchY = boundedY;
setThumbOffset(mRv.getScrollBarX(), (int) mLastTouchY);
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mTouchOffset = 0;
mLastTouchY = 0;
mIgnoreDragGesture = false;
if (mIsDragging) {
mIsDragging = false;
mPopup.animateVisibility(false);
showActiveScrollbar(false);
}
break;
}
}
示例14: onInterceptTouchEvent
import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return scrollOffsetY != 0 && ev.getY() < scrollOffsetY || super.onInterceptTouchEvent(ev);
}
示例15: getAreaFlag
import android.view.MotionEvent; //导入方法依赖的package包/类
public int getAreaFlag(MotionEvent e)
{
int top = mThumbMarginTop;
int bottom = mThumbHeight + mThumbMarginTop;
if(e.getY() >= top && e.getY() <= bottom && e.getX() >= (mOffsetLow - mHalfThumbWidth) && e
.getX() <= mOffsetLow + mHalfThumbWidth)
{
return CLICK_ON_LOW;
}
else if(e.getY() >= top && e.getY() <= bottom && e
.getX() >= (mOffsetHigh - mHalfThumbWidth) && e
.getX() <= (mOffsetHigh + mHalfThumbWidth))
{
return CLICK_ON_HIGH;
}
else if(e.getY() >= top
&& e.getY() <= bottom
&& ((e.getX() >= 0 && e.getX() < (mOffsetLow - mHalfThumbWidth)) || ((e
.getX() > (mOffsetLow + mHalfThumbWidth))
&& e.getX() <= ((double) mOffsetHigh + mOffsetLow) / 2)))
{
return CLICK_IN_LOW_AREA;
}
else if(e.getY() >= top
&& e.getY() <= bottom
&& (((e.getX() > ((double) mOffsetHigh + mOffsetLow) / 2) && e
.getX() < (mOffsetHigh - mHalfThumbWidth)) || (e
.getX() > (mOffsetHigh + mHalfThumbWidth) && e.getX() <= mScrollBarWidth)))
{
return CLICK_IN_HIGH_AREA;
}
else if(!(e.getX() >= 0 && e.getX() <= mScrollBarWidth && e.getY() >= top && e
.getY() <= bottom))
{
return CLICK_OUT_AREA;
}
else
{
return CLICK_INVALID;
}
}