本文整理了Java中android.view.MotionEvent.offsetLocation()
方法的一些代码示例,展示了MotionEvent.offsetLocation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MotionEvent.offsetLocation()
方法的具体详情如下:
包路径:android.view.MotionEvent
类名称:MotionEvent
方法名:offsetLocation
暂无
代码示例来源:origin: rey5137/material
/**
* Emulates View.toLocalMotionEvent(). This implementation does not handle transformations
* (scaleX, scaleY, etc).
*/
private boolean toLocalMotionEvent(View view, MotionEvent event) {
final int[] loc = mTmpLocation;
view.getLocationOnScreen(loc);
event.offsetLocation(-loc[0], -loc[1]);
return true;
}
代码示例来源:origin: rey5137/material
/**
* Emulates View.toGlobalMotionEvent(). This implementation does not handle transformations
* (scaleX, scaleY, etc).
*/
private boolean toGlobalMotionEvent(View view, MotionEvent event) {
final int[] loc = mTmpLocation;
view.getLocationOnScreen(loc);
event.offsetLocation(loc[0], loc[1]);
return true;
}
代码示例来源:origin: EverythingMe/overscroll-decor
@Override
protected void translateViewAndEvent(View view, float offset, MotionEvent event) {
view.setTranslationY(offset);
event.offsetLocation(offset - event.getY(0), 0f);
}
}
代码示例来源:origin: EverythingMe/overscroll-decor
@Override
protected void translateViewAndEvent(View view, float offset, MotionEvent event) {
view.setTranslationX(offset);
event.offsetLocation(offset - event.getX(0), 0f);
}
}
代码示例来源:origin: Ramotion/expanding-collection-android
@Override
public boolean onTouchEvent(MotionEvent ev) {
// We capture any touches not already handled by the ViewPager
// to implement scrolling from a touch outside the pager bounds.
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
initialTouch.x = (int) ev.getX();
initialTouch.y = (int) ev.getY();
default:
ev.offsetLocation(center.x - initialTouch.x, center.y - initialTouch.y);
break;
}
return pager.dispatchTouchEvent(ev);
}
代码示例来源:origin: seven332/EhViewer
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
if (mSeekBar == null) {
return super.onTouchEvent(event);
} else {
ViewUtils.getLocationInAncestor(mSeekBar, mLocation, this);
final float offsetX = -mLocation[0];
final float offsetY = -mLocation[1];
event.offsetLocation(offsetX, offsetY);
mSeekBar.onTouchEvent(event);
event.offsetLocation(-offsetX, -offsetY);
return true;
}
}
代码示例来源:origin: ksoichiro/Android-ObservableScrollView
if (pe != null) {
MotionEvent peAdjusted = MotionEvent.obtainNoHistory(pe);
peAdjusted.offsetLocation(offsetX, offsetY);
consumed |= childView.dispatchTouchEvent(peAdjusted);
event.offsetLocation(offsetX, offsetY);
consumed |= childView.dispatchTouchEvent(event);
if (consumed) {
代码示例来源:origin: Justson/AgentWeb
event.offsetLocation(0, mNestedYOffset);
trackedEvent.offsetLocation(0, mScrollOffset[1]);
mNestedYOffset += mScrollOffset[1];
trackedEvent.offsetLocation(0, mScrollOffset[1]);
mNestedYOffset += mScrollOffset[1];
代码示例来源:origin: ksoichiro/Android-ObservableScrollView
event.offsetLocation(offsetX, offsetY);
代码示例来源:origin: ksoichiro/Android-ObservableScrollView
event.offsetLocation(offsetX, offsetY);
代码示例来源:origin: ksoichiro/Android-ObservableScrollView
event.offsetLocation(offsetX, offsetY);
代码示例来源:origin: ksoichiro/Android-ObservableScrollView
event.offsetLocation(offsetX, offsetY);
代码示例来源:origin: ksoichiro/Android-ObservableScrollView
event.offsetLocation(offsetX, offsetY);
代码示例来源:origin: alexvasilkov/GestureViews
protected boolean onTouchInternal(@NonNull View view, @NonNull MotionEvent event) {
MotionEvent viewportEvent = MotionEvent.obtain(event);
viewportEvent.offsetLocation(-view.getPaddingLeft(), -view.getPaddingTop());
代码示例来源:origin: Flipboard/bottomsheet
if (state == State.PEEKED) {
MotionEvent cancelEvent = MotionEvent.obtain(event);
cancelEvent.offsetLocation(0, sheetTranslation - getHeight());
cancelEvent.setAction(MotionEvent.ACTION_CANCEL);
getSheetView().dispatchTouchEvent(cancelEvent);
event.offsetLocation(0, sheetTranslation - getHeight());
getSheetView().dispatchTouchEvent(event);
} else {
event.offsetLocation(isTablet ? getX() - sheetStartX : 0, sheetTranslation - getHeight());
getSheetView().dispatchTouchEvent(event);
代码示例来源:origin: recruit-lifestyle/FloatingView
/**
* Call addMovement and restore MotionEvent coordinate
*
* @param event {@link MotionEvent}
*/
private void addMovement(@NonNull MotionEvent event) {
final float deltaX = event.getRawX() - event.getX();
final float deltaY = event.getRawY() - event.getY();
event.offsetLocation(deltaX, deltaY);
mVelocityTracker.addMovement(event);
event.offsetLocation(-deltaX, -deltaY);
}
代码示例来源:origin: weexteam/weex-hackernews
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
mRedirectTouchToStickyView = true;
}
if (mRedirectTouchToStickyView) {
mRedirectTouchToStickyView = mCurrentStickyView != null;
if (mRedirectTouchToStickyView) {
mRedirectTouchToStickyView = ev.getY() <= mCurrentStickyView.getHeight()
&& ev.getX() >= mCurrentStickyView.getLeft()
&& ev.getX() <= mCurrentStickyView.getRight();
}
}
if (mRedirectTouchToStickyView) {
if (mScrollRect == null) {
mScrollRect = new Rect();
getGlobalVisibleRect(mScrollRect);
}
mCurrentStickyView.getLocationOnScreen(stickyViewP);
ev.offsetLocation(0, stickyViewP[1] - mScrollRect.top);
}
return super.dispatchTouchEvent(ev);
}
代码示例来源:origin: robolectric/robolectric
event.offsetLocation(-3, -2);
代码示例来源:origin: robolectric/robolectric
@Test
public void testOffsetLocation() {
assertThat(motionEvent2).x().isWithin(TOLERANCE).of(X_3F);
assertThat(motionEvent2).y().isWithin(TOLERANCE).of(Y_4F);
float offsetX = 1.0f;
float offsetY = 1.0f;
motionEvent2.offsetLocation(offsetX, offsetY);
assertThat(motionEvent2).x().isWithin(TOLERANCE).of(X_3F + offsetX);
assertThat(motionEvent2).y().isWithin(TOLERANCE).of(Y_4F + offsetY);
}
代码示例来源:origin: weexteam/weex-hackernews
ev.offsetLocation(0, -(stickyViewP[1] - mScrollRect.top));
内容来源于网络,如有侵权,请联系作者删除!