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


Java MotionEvent.getRawY方法代碼示例

本文整理匯總了Java中android.view.MotionEvent.getRawY方法的典型用法代碼示例。如果您正苦於以下問題:Java MotionEvent.getRawY方法的具體用法?Java MotionEvent.getRawY怎麽用?Java MotionEvent.getRawY使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.MotionEvent的用法示例。


在下文中一共展示了MotionEvent.getRawY方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onInterceptTouchEvent

import android.view.MotionEvent; //導入方法依賴的package包/類
@Override
public boolean onInterceptTouchEvent(MotionEvent e) {
	int y = (int) e.getRawY();
	switch (e.getAction()) {
	case MotionEvent.ACTION_DOWN:
		// 首先攔截down事件,記錄y坐標
		mLastMotionY = y;
		break;
	case MotionEvent.ACTION_MOVE:
		// deltaY > 0 是向下運動,< 0是向上運動
		int deltaY = y - mLastMotionY;
		if (isRefreshViewScroll(deltaY)) {
			return true;
		}
		break;
	case MotionEvent.ACTION_UP:
	case MotionEvent.ACTION_CANCEL:
		break;
	}
	return false;
}
 
開發者ID:SShineTeam,項目名稱:Huochexing12306,代碼行數:22,代碼來源:PullToRefreshView.java

示例2: updateWindow

import android.view.MotionEvent; //導入方法依賴的package包/類
/**
 * 觸摸移動時,window更新
 *
 * @param ev
 */
private void updateWindow(MotionEvent ev) {
    if (mode == MODE_DRAG) {
        float x = ev.getRawX() - mX;
        float y = ev.getRawY() - mY;
        if (layoutParams != null) {
            layoutParams.x = (int) x;
            layoutParams.y = (int) y;
            mWindowManager.updateViewLayout(dragView, layoutParams);
        }
        float mx = ev.getX();
        float my = ev.getY();
        int dropPosition = pointToPosition((int) mx, (int) my);
        Log.i(TAG, "dropPosition : " + dropPosition + " , tempPosition : " + tempPosition);
        if (dropPosition == tempPosition || dropPosition == GridView.INVALID_POSITION) {
            return;
        }
        itemMove(tempPosition,dropPosition);
    }
}
 
開發者ID:droptea,項目名稱:tv_move_gridView,代碼行數:25,代碼來源:DragGridView.java

示例3: onInterceptTouchEvent

import android.view.MotionEvent; //導入方法依賴的package包/類
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    int y = (int) ev.getRawY();
    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            lastY = y;
            break;
        case MotionEvent.ACTION_MOVE:
            int deltaY = y - lastY;
            if (isParentViewScroll(deltaY)) {
                Log.e(TAG, "onInterceptTouchEvent: belong to ParentView");
                return true; //此時,觸發onTouchEvent事件
            }
            break;
        default:
            break;
    }
    return false;
}
 
開發者ID:REBOOTERS,項目名稱:UltimateRefreshView,代碼行數:20,代碼來源:UltimateRefreshView.java

示例4: onTouchEvent

import android.view.MotionEvent; //導入方法依賴的package包/類
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (scroller.computeScrollOffset()) {
        return super.onTouchEvent(event);
    }
    curX = event.getRawX();
    curY = event.getRawY();
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            downX = lastX = event.getRawX();
            downY = lastY = event.getRawY();
            break;
        case MotionEvent.ACTION_MOVE:
            onMove();
            lastX = curX;
            lastY = curY;
            break;
        case MotionEvent.ACTION_UP:
            onScrollEdge();
            break;
    }
    return true;
}
 
開發者ID:FreeSunny,項目名稱:Amazing,代碼行數:24,代碼來源:DragFrameLayout.java

示例5: onInterceptTouchEvent

import android.view.MotionEvent; //導入方法依賴的package包/類
@Override
public boolean onInterceptTouchEvent(MotionEvent e) {
    int action = e.getAction();
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            downX = (int) e.getRawX();
            downY = (int) e.getRawY();
            break;
        case MotionEvent.ACTION_MOVE:
            int moveY = (int) e.getRawY();
            if (Math.abs(moveY - downY) > mTouchSlop) {
                return true;
            }
    }
    return super.onInterceptTouchEvent(e);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:MyScrollview.java

示例6: onTouchEvent

import android.view.MotionEvent; //導入方法依賴的package包/類
@Override
public boolean onTouchEvent(MotionEvent ev) {
    if (null == coordinatorListener) {
        return super.onTouchEvent(ev);
    }
    final int action = ev.getAction();
    final int y = (int) ev.getRawY();
    final int x = (int) ev.getRawX();
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            downPositionY = ev.getRawY();
            break;
        case MotionEvent.ACTION_MOVE:
            int deltaY = (int) (downPositionY - y);
            boolean deal;
            if (isScrollTop(ev)) {
                deal = coordinatorListener.onCoordinateScroll(x, y, 0, deltaY + Math.abs(dragDistanceY), true);
            } else {
                deal = coordinatorListener.onCoordinateScroll(x, y, 0, deltaY, isScrollTop(ev));
            }
            if (deal) {
                return true;
            }
            break;
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            scrollTop = false;
            if (coordinatorListener.isBeingDragged()) {
                coordinatorListener.onSwitch();
                return true;
            }
            break;
    }
    return super.onTouchEvent(ev);
}
 
開發者ID:Skykai521,項目名稱:InstagramPhotoPicker,代碼行數:36,代碼來源:CoordinatorRecyclerView.java

示例7: onTouchEvent

import android.view.MotionEvent; //導入方法依賴的package包/類
public Boolean onTouchEvent(MotionEvent event) {
    this.gestureDetector.onTouchEvent(event);
    this.previousTouchX = this.currentX;
    this.previousTouchY = this.currentY;
    this.currentX = event.getRawX();
    this.currentY = event.getRawY();
    switch (event.getActionMasked()) {
        case 1:
        case 3:
            if (this.relocationState == eRelocationState.Relocating) {
                if (this.overTrashCan.booleanValue()) {
                    beginTrashingView();
                } else {
                    endRelocateTab(new PointF(0.0f, 0.0f));
                }
                return Boolean.valueOf(true);
            }
            break;
        case 2:
            if (this.relocationState == eRelocationState.Relocating) {
                updateRelocateTab(this.currentX, this.currentY);
                return Boolean.valueOf(true);
            }
            break;
    }
    return Boolean.valueOf(false);
}
 
開發者ID:bunnyblue,項目名稱:NoticeDog,代碼行數:28,代碼來源:SwipeTabViewRelocationController.java

示例8: setTouchDXY

import android.view.MotionEvent; //導入方法依賴的package包/類
void setTouchDXY(MotionEvent e, float damp) {
    float X = e.getRawX();
    float Y = e.getRawY();
    touchDX = (int) ((X - touchLastX) * damp);
    touchDY = (int) ((Y - touchLastY) * damp);
    setTouchLastXY(X, Y);
    //LogUtil.d("DY : " + touchDY);
}
 
開發者ID:anmingyu11,項目名稱:OverScrollableRecyclerView-Method1,代碼行數:9,代碼來源:AViewState.java

示例9: isAbleToScroll

import android.view.MotionEvent; //導入方法依賴的package包/類
/**
 * 判斷是否可以下滑
 * @param event
 * @return
 */
private boolean isAbleToScroll(MotionEvent event) {
    View firstNoRefreshChild = getChildAt(1);
    if(firstNoRefreshChild != null){
        if(firstNoRefreshChild.getTop() >= 0){
            if(!isAbleToPull){
                mFingerDownY = (int) event.getRawY();
            }
            isAbleToPull = true;
        }else{
            isAbleToPull = false;
        }
    }else{
        isAbleToPull = true;
    }
    /*if(!canScrollUp()){
        if(!isAbleToPull){
            mFingerDownY = (int) event.getRawY();
        }
        isAbleToPull = true;
    }else{
        isAbleToPull = false;
    }
    //Log.e("能否滑動",!canScrollUp()+"");*/

    return isAbleToPull;
}
 
開發者ID:chengkun123,項目名稱:ReadMark,代碼行數:32,代碼來源:RefreshRecyclerView.java

示例10: trackMovement

import android.view.MotionEvent; //導入方法依賴的package包/類
private void trackMovement(MotionEvent event) {
    float deltaX = event.getRawX() - event.getX();
    float deltaY = event.getRawY() - event.getY();
    event.offsetLocation(deltaX, deltaY);
    if (this.mVelocityTracker != null) {
        this.mVelocityTracker.addMovement(event);
    }
    event.offsetLocation(-deltaX, -deltaY);
}
 
開發者ID:bunnyblue,項目名稱:NoticeDog,代碼行數:10,代碼來源:PanelView.java

示例11: onTouchEvent

import android.view.MotionEvent; //導入方法依賴的package包/類
@Override
public boolean onTouchEvent(MotionEvent e) {
    if(mCurrentLoadStatus == LOAD_STATUS_LOADING || isAutoScroll){
        //Log.e(TAG, "在刷新狀態進入");
        return true;
    }else if(!canScrollDown()){
        //能滾動的時候初次記錄Y
        if(isTmpFirstDown){
            mFingerDownY = (int) e.getRawY();
            isTmpFirstDown = false;
        }
        switch(e.getAction()){
            case MotionEvent.ACTION_MOVE:
                if (mLoadCreator != null) {
                    mLoadViewHeight = mLoadView.getMeasuredHeight();
                }
                // 解決上拉加載更多自動滾動問題
                /*if (mCurrentDrag) {
                    scrollToPosition(getAdapter().getItemCount() - 1);
                }*/

                // 獲取手指觸摸拖拽的距離
                int distanceY = (int) ((e.getRawY() - mFingerDownY) * mDragIndex);
                // 如果是已經到達頭部,並且不斷的向下拉,那麽不斷的改變refreshView的marginTop的值
                if (distanceY < 0) {
                    //和底部的margin是-Y
                    setLoadViewMarginBottom(-distanceY);
                    updateLoadStatus(-distanceY);
                    mCurrentDrag = true;
                    return true;
                }
                break;
        }
    }

    return super.onTouchEvent(e);
}
 
開發者ID:chengkun123,項目名稱:ReadMark,代碼行數:38,代碼來源:LoadRefreshRecyclerView.java

示例12: onTouch

import android.view.MotionEvent; //導入方法依賴的package包/類
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    if (!isDrop) {
        switch (motionEvent.getAction()) {
            case MotionEvent.ACTION_DOWN:
                yDown = motionEvent.getRawY();
                break;
            case MotionEvent.ACTION_MOVE:
                float yMove = motionEvent.getRawY();
                distance = (int) ((yMove - yDown) / 4);
                if (distance <= 0) {
                    layout(getLeft(), 0, getRight(), getBottom());
                    return false;
                }
                layout(getLeft(), distance, getRight(), getBottom());
                break;
            case MotionEvent.ACTION_UP:
                if (distance > 0 && distance < 200) {
                    animToTop();
                }
                if (distance >= 200) {
                    layout(getLeft(), 200, getRight(), getBottom());
                    isDrop = true;
                    new Thread(new Runnable() {
                        @Override
                        public void run() {
                            try {
                                Thread.sleep(2000);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                            animToTop();
                        }
                    }).start();
                }
        }
    }
    return true;
}
 
開發者ID:shenhuanet,項目名稱:AndroidOpen,代碼行數:40,代碼來源:DropTopLinearLayout.java

示例13: onTouch

import android.view.MotionEvent; //導入方法依賴的package包/類
@Override
public boolean onTouch(View v, MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        mLastTouchX = (int) event.getRawX();
        mLastTouchY = (int) event.getRawY();
    }
    return false;
}
 
開發者ID:SalmanTKhan,項目名稱:MyAnimeViewer,代碼行數:9,代碼來源:AnimeRecyclerAdapter.java

示例14: onTouchEvent

import android.view.MotionEvent; //導入方法依賴的package包/類
@Override
public boolean onTouchEvent(MotionEvent ev) {
    if (mLastY == -1) {
        mLastY = ev.getRawY();
    }
    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            mLastY = ev.getRawY();
            break;
        case MotionEvent.ACTION_MOVE:
            final float deltaY = ev.getRawY() - mLastY;
            mLastY = ev.getRawY();
            if (isOnTop() && pullRefreshEnabled && appbarState == AppBarStateChangeListener.State.EXPANDED) {
                mRefreshHeader.onMove(deltaY / DRAG_RATE);
                if (mRefreshHeader.getVisibleHeight() > 0 && mRefreshHeader.getState() < ArrowRefreshHeader.STATE_REFRESHING) {
                    return false;
                }
            }
            break;
        default:
            mLastY = -1; // reset
            if (isOnTop() && pullRefreshEnabled && appbarState == AppBarStateChangeListener.State.EXPANDED) {
                if (mRefreshHeader.releaseAction()) {
                    if (mLoadingListener != null) {
                        mLoadingListener.onRefresh();
                    }
                }
            }
            break;
    }
    return super.onTouchEvent(ev);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:33,代碼來源:XRecyclerView.java

示例15: onInterceptTouchEvent

import android.view.MotionEvent; //導入方法依賴的package包/類
/**
     * ④重寫ViewGroup的onInterceptTouchEvent(MotionEvent ev)用來攔截事件
     */
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        boolean handled = false;
        mTouchX = ev.getRawX();
        mTouchY = ev.getRawY();
        if (isEnabled()) {
            if (mCurDragDirection == NONE) {
                switch (ev.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        downX = mTouchX;
                        downY = mTouchY;
                        break;
                    case MotionEvent.ACTION_MOVE:
                        float slope = (mTouchY - downY) / (mTouchX - downX);
                        mCurDragDirection = Math.abs(slope) >= 1 ? (mTouchY > downY ? UP : DOWN) : (mTouchX > downX ? LEFT : RIGHT);
                        break;
                }
                if (mContentView instanceof ViewGroup) {
                    findScrollView((ViewGroup) mContentView);
                } else mScrollChild = mContentView;
            }
//            Log.e("zhou", "-------mCurDragDirection-------------"+mCurDragDirection);

            handled = mViewDragHelper.shouldInterceptTouchEvent(ev) ;
        } else {
            mViewDragHelper.cancel();
        }
        if (!handled) {
            mCurDragDirection = NONE;
            mScrollChild = mContentView;
        }
        return handled || super.onInterceptTouchEvent(ev);
    }
 
開發者ID:zhouphenix,項目名稱:Multi-SwipeBackLayout,代碼行數:37,代碼來源:SwipeBackLayout.java


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