本文整理匯總了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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}