當前位置: 首頁>>代碼示例>>Java>>正文


Java MotionEvent.getY方法代碼示例

本文整理匯總了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;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:22,代碼來源:AppWidgetResizeFrame.java

示例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;
}
 
開發者ID:google,項目名稱:spline,代碼行數:20,代碼來源:SaturationValuePicker.java

示例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;
}
 
開發者ID:Shmilyz,項目名稱:Swap,代碼行數:33,代碼來源:NumberKeyboardView.java

示例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();
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:29,代碼來源:StickLayout2.java

示例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;
}
 
開發者ID:ovenbits,項目名稱:QuickActionView,代碼行數:10,代碼來源:QuickActionView.java

示例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;
}
 
開發者ID:mangoblogger,項目名稱:MangoBloggerAndroidApp,代碼行數:47,代碼來源:LikeButton.java

示例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);
}
 
開發者ID:android-jian,項目名稱:topnews,代碼行數:35,代碼來源:CircleNavigator.java

示例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);
    }
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:28,代碼來源:PagedView.java

示例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; 
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:13,代碼來源:ZoomTouchView.java

示例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;
}
 
開發者ID:rozdoum,項目名稱:social-app-android,代碼行數:15,代碼來源:TouchImageView.java

示例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;
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:73,代碼來源:ScrollLayout.java

示例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;
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:51,代碼來源:RefreshLayout.java

示例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;
    }
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:59,代碼來源:BaseRecyclerViewFastScrollBar.java

示例14: onInterceptTouchEvent

import android.view.MotionEvent; //導入方法依賴的package包/類
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    return scrollOffsetY != 0 && ev.getY() < scrollOffsetY || super.onInterceptTouchEvent(ev);
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:5,代碼來源:ShareAlert.java

示例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;
    }
}
 
開發者ID:Ayvytr,項目名稱:EasyAndroid,代碼行數:43,代碼來源:SeekBarPressure.java


注:本文中的android.view.MotionEvent.getY方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。