当前位置: 首页>>代码示例>>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;未经允许,请勿转载。