本文整理汇总了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);
}