本文整理了Java中android.view.MotionEvent.setLocation()
方法的一些代码示例,展示了MotionEvent.setLocation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MotionEvent.setLocation()
方法的具体详情如下:
包路径:android.view.MotionEvent
类名称:MotionEvent
方法名:setLocation
暂无
代码示例来源:origin: alexvasilkov/GestureViews
private MotionEvent applyMatrix(MotionEvent event, Matrix matrix) {
tmpPointArray[0] = event.getX();
tmpPointArray[1] = event.getY();
matrix.mapPoints(tmpPointArray);
MotionEvent copy = MotionEvent.obtain(event);
copy.setLocation(tmpPointArray[0], tmpPointArray[1]);
return copy;
}
代码示例来源:origin: stackoverflow.com
m_webView.setHorizontalScrollBarEnabled(false);
m_webView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getPointerCount() > 1) {
//Multi touch detected
return true;
}
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
// save the x
m_downX = event.getX();
}
break;
case MotionEvent.ACTION_MOVE:
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP: {
// set x so that it doesn't move
event.setLocation(m_downX, event.getY());
}
break;
}
return false;
}
});
代码示例来源:origin: seven332/EhViewer
@Override
public boolean onTouchEvent(MotionEvent event) {
boolean reverse = mReverse;
float x = 0.0f, y = 0.0f;
if (reverse) {
x = event.getX();
y = event.getY();
event.setLocation(getWidth() - x, y);
}
boolean result = super.onTouchEvent(event);
if (reverse) {
event.setLocation(x, y);
}
return result;
}
}
代码示例来源:origin: davemorrissey/subsampling-scale-image-view
private MotionEvent swapXY(MotionEvent ev) {
float width = getWidth();
float height = getHeight();
float newX = (ev.getY() / height) * width;
float newY = (ev.getX() / width) * height;
ev.setLocation(newX, newY);
return ev;
}
代码示例来源:origin: willowtreeapps/spruce-android
private MotionEvent swapXY(MotionEvent ev) {
float width = getWidth();
float height = getHeight();
float newX = (ev.getY() / height) * width;
float newY = (ev.getX() / width) * height;
ev.setLocation(newX, newY);
return ev;
}
代码示例来源:origin: facebook/litho
if (touchWithinViewBounds) {
event.setLocation(mDelegateView.getWidth() / 2, mDelegateView.getHeight() / 2);
} else {
event.setLocation(-(mSlop * 2), -(mSlop * 2));
代码示例来源:origin: ksoichiro/Android-ObservableScrollView
event.setLocation(ev.getX(), ev.getY());
mTouchInterceptionListener.onDownMotionEvent(event);
mDownMotionEventPended = false;
MotionEvent event = MotionEvent.obtainNoHistory(mPendingDownMotionEvent);
event.setLocation(ev.getX(), ev.getY());
duplicateTouchEventForChildren(ev, event);
} else {
mDownMotionEventPended = false;
MotionEvent event = MotionEvent.obtainNoHistory(mPendingDownMotionEvent);
event.setLocation(ev.getX(), ev.getY());
duplicateTouchEventForChildren(ev, event);
} else {
代码示例来源:origin: alexvasilkov/GestureViews
private void passEventToViewPager(@NonNull MotionEvent event) {
if (viewPager == null) {
return;
}
MotionEvent fixedEvent = obtainOnePointerEvent(event);
fixedEvent.setLocation(lastViewPagerEventX, 0f);
if (isViewPagerInterceptedScroll) {
viewPager.onTouchEvent(fixedEvent);
} else {
isViewPagerInterceptedScroll = viewPager.onInterceptTouchEvent(fixedEvent);
}
// If ViewPager intercepted touch it will settle itself automatically,
// but if touch was not intercepted we should settle it manually
if (!isViewPagerInterceptedScroll && hasViewPagerX()) {
settleViewPagerIfFinished(viewPager, event);
}
// Hack: ViewPager has bug when endFakeDrag() does not work properly. But we need to ensure
// ViewPager is not in fake drag mode after settleViewPagerIfFinished()
try {
if (viewPager != null && viewPager.isFakeDragging()) {
viewPager.endFakeDrag();
}
} catch (Exception ignored) {
}
fixedEvent.recycle();
}
代码示例来源:origin: stackoverflow.com
event.setLocation(this.getWidth() - event.getX(), event.getY());
代码示例来源:origin: stackoverflow.com
public class TouchDelegateComposite extends TouchDelegate {
private final List<TouchDelegate> delegates = new ArrayList<TouchDelegate>();
private static final Rect emptyRect = new Rect();
public TouchDelegateComposite(View view) {
super(emptyRect, view);
}
public void addDelegate(TouchDelegate delegate) {
if (delegate != null) {
delegates.add(delegate);
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
boolean res = false;
float x = event.getX();
float y = event.getY();
for (TouchDelegate delegate : delegates) {
event.setLocation(x, y);
res = delegate.onTouchEvent(event) || res;
}
return res;
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testSetLocation() {
assertThat(motionEvent2).x().isWithin(TOLERANCE).of(X_3F);
assertThat(motionEvent2).y().isWithin(TOLERANCE).of(Y_4F);
motionEvent2.setLocation(2.0f, 2.0f);
assertThat(motionEvent2).x().isWithin(TOLERANCE).of(2.0f);
assertThat(motionEvent2).y().isWithin(TOLERANCE).of(2.0f);
}
代码示例来源:origin: weexteam/weex-hackernews
ev.setLocation(clampedX+consumed[0],clampedY+consumed[1]);
代码示例来源:origin: stackoverflow.com
me.setLocation(__e.getX() - dragDeltaX, __e.getY() - dragDeltaY);
super.onTouchEvent(me);
代码示例来源:origin: limboemu/limbo
/**
* Modify the event so that it does not move the mouse on the remote
* server.
*
* @param e
*/
private void remoteMouseStayPut(MotionEvent e) {
e.setLocation(vncCanvas.mouseX, vncCanvas.mouseY);
}
代码示例来源:origin: stackoverflow.com
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
event.setLocation(event.getY(), event.getX());
return super.onTouchEvent(event);
}
代码示例来源:origin: stackoverflow.com
HorizontalScrollView hsv;
hsv.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
event.setLocation(-1*event.getX(), event.getY());
hsv.dispatchTouchEvent(ev);
return true;
}
})
代码示例来源:origin: elevenetc/InteractiveCanvas
@Override public boolean onTouchEvent(MotionEvent event) {
if (touchHandler != null) {
event.setLocation(event.getX() - dx, event.getY() - dy);
touchHandler.handleTouchEvent(event);
return true;
} else {
return super.onTouchEvent(event);
}
}
代码示例来源:origin: PrivacyApps/document-viewer
private MotionEvent calculateCenterEvent(final MotionEvent ev) {
final PointF center = calculateCenter(ev);
final MotionEvent newEvent = MotionEvent.obtain(ev);
newEvent.setLocation(center.x, center.y);
return newEvent;
}
代码示例来源:origin: armcha/Vertical-Intro
private MotionEvent swapXY(MotionEvent ev) {
float width = getWidth();
float height = getHeight();
float newX = (ev.getY() / height) * width;
float newY = (ev.getX() / width) * height;
ev.setLocation(newX, newY);
return ev;
}
代码示例来源:origin: crvv/android_wubi_input
public boolean onTouchEvent(final int x, final int y, final MotionEvent me) {
mReceiverView.getGlobalVisibleRect(mEventReceivingRect);
// Translate global coordinates to <code>ReceiverView</code> local coordinates.
me.setLocation(translateX(x), translateY(y));
mReceiverView.dispatchTouchEvent(me);
onForwardingEvent(me);
return true;
}
}
内容来源于网络,如有侵权,请联系作者删除!