本文整理了Java中android.view.MotionEvent.getXPrecision()
方法的一些代码示例,展示了MotionEvent.getXPrecision()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MotionEvent.getXPrecision()
方法的具体详情如下:
包路径:android.view.MotionEvent
类名称:MotionEvent
方法名:getXPrecision
暂无
代码示例来源:origin: TonicArtos/StickyGridHeaders
private MotionEvent transformEvent(MotionEvent e, int headerPosition) {
if (headerPosition == MATCHED_STICKIED_HEADER) {
return e;
}
long downTime = e.getDownTime();
long eventTime = e.getEventTime();
int action = e.getAction();
int pointerCount = e.getPointerCount();
int[] pointerIds = getPointerIds(e);
MotionEvent.PointerCoords[] pointerCoords = getPointerCoords(e);
int metaState = e.getMetaState();
float xPrecision = e.getXPrecision();
float yPrecision = e.getYPrecision();
int deviceId = e.getDeviceId();
int edgeFlags = e.getEdgeFlags();
int source = e.getSource();
int flags = e.getFlags();
View headerHolder = getChildAt(headerPosition);
for (int i = 0; i < pointerCount;i++) {
pointerCoords[i].y -= headerHolder.getTop();
}
MotionEvent n = MotionEvent.obtain(downTime, eventTime, action,
pointerCount, pointerIds, pointerCoords, metaState, xPrecision,
yPrecision, deviceId, edgeFlags, source, flags);
return n;
}
代码示例来源:origin: robolectric/robolectric
check("getFlags()").that(actual().getFlags()).isEqualTo(other.getFlags());
check("getEdgeFlags()").that(actual().getEdgeFlags()).isEqualTo(other.getEdgeFlags());
check("getXPrecision()").that(actual().getXPrecision()).isEqualTo(other.getXPrecision());
check("getYPrecision()").that(actual().getYPrecision()).isEqualTo(other.getYPrecision());
代码示例来源:origin: stackoverflow.com
ImageView iv;
iv.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
event.getX();
event.getX(pointerIndex)
event.getXPrecision()
return true;
}
});
代码示例来源:origin: stackoverflow.com
rl = (RelativeLayout) findViewById(R.id.rl);
rl.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
float x = event.getX()*event.getXPrecision();
float y = event.getY()*event.getYPrecision();
Button btn = new Button(getApplicationContext());
RelativeLayout.LayoutParams bp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
bp.leftMargin = (int) x;
bp.topMargin = (int) y;
btn.setLayoutParams(bp);
rl.addView(btn);
return false;
}
});
代码示例来源:origin: stackoverflow.com
public OnTouchListener nextListener = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
float x = event.getX()*event.getXPrecision();
float y = event.getY()*event.getYPrecision();
FrameLayout.LayoutParams p = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
p.gravity = Gravity.TOP;
p.leftMargin = (int) x;
p.topMargin = (int) y;
b.setLayoutParams(p);
return true;
}
return false;
}
};
代码示例来源:origin: stackoverflow.com
public boolean dispatchTouchEvent(MotionEvent ev) {
if(pointToPosition((int) (ev.getX() * ev.getXPrecision()),
(int) (ev.getY() * ev.getYPrecision())) == -1 && ev.getAction() == MotionEvent.ACTION_DOWN) {
if(mOnNoItemClickListener != null) {
代码示例来源:origin: qiubiteme/android_api_demos
@Override
public boolean onTrackballEvent(MotionEvent event) {
final int action = event.getActionMasked();
if (action == MotionEvent.ACTION_DOWN) {
// Advance color when the trackball button is pressed.
advanceColor();
}
if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE) {
final int N = event.getHistorySize();
final float scaleX = event.getXPrecision() * TRACKBALL_SCALE;
final float scaleY = event.getYPrecision() * TRACKBALL_SCALE;
for (int i = 0; i < N; i++) {
moveTrackball(event.getHistoricalX(i) * scaleX,
event.getHistoricalY(i) * scaleY);
}
moveTrackball(event.getX() * scaleX, event.getY() * scaleY);
}
return true;
}
代码示例来源:origin: THEONE10211024/ApiDemos
@Override
public boolean onTrackballEvent(MotionEvent event) {
final int action = event.getActionMasked();
if (action == MotionEvent.ACTION_DOWN) {
// Advance color when the trackball button is pressed.
advanceColor();
}
if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE) {
final int N = event.getHistorySize();
final float scaleX = event.getXPrecision() * TRACKBALL_SCALE;
final float scaleY = event.getYPrecision() * TRACKBALL_SCALE;
for (int i = 0; i < N; i++) {
moveTrackball(event.getHistoricalX(i) * scaleX,
event.getHistoricalY(i) * scaleY);
}
moveTrackball(event.getX() * scaleX, event.getY() * scaleY);
}
return true;
}
代码示例来源:origin: stackoverflow.com
MotionEvent evt = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), event
.getAction(), coords[0], coords[1], event.getPressure(), event.getSize(), event
.getMetaState(), event.getXPrecision(), event.getYPrecision(), event.getDeviceId(),
event.getEdgeFlags());
return super.dispatchTouchEvent(evt);
代码示例来源:origin: gqjjqg/android-extend
ev.getEventTime(), ev.getAction(), newPoint.x, newPoint.y,
ev.getPressure(), ev.getSize(), ev.getMetaState(),
ev.getXPrecision(), ev.getYPrecision(), ev.getDeviceId(),
ev.getEdgeFlags());
} else {
coor, ev.getMetaState(), ev.getButtonState(), ev.getXPrecision(), ev.getYPrecision(), ev.getDeviceId(),
ev.getEdgeFlags(), ev.getSource(), ev.getFlags());
代码示例来源:origin: stackoverflow.com
.obtain(event.getDownTime(), event.getEventTime(), event.getAction(), x, y,
event.getPressure(), event.getSize(), event.getMetaState(),
event.getYPrecision(), event.getXPrecision(), event.getDeviceId(),
event.getEdgeFlags());
return super.onTouchEvent(verticalEvent);
代码示例来源:origin: stackoverflow.com
MotionEvent evt = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), event
.getAction(), coords[0], coords[1], event.getPressure(), event.getSize(), event
.getMetaState(), event.getXPrecision(), event.getYPrecision(), event.getDeviceId(),
event.getEdgeFlags());
return super.dispatchTouchEvent(evt);
代码示例来源:origin: stackoverflow.com
MotionEvent evt = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), event
.getAction(), coords[0], coords[1], event.getPressure(), event.getSize(), event
.getMetaState(), event.getXPrecision(), event.getYPrecision(), event.getDeviceId(),
event.getEdgeFlags());
return super.dispatchTouchEvent(evt);
代码示例来源:origin: stackoverflow.com
MotionEvent evt = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), event
.getAction(), coords[0], coords[1], event.getPressure(), event.getSize(), event
.getMetaState(), event.getXPrecision(), event.getYPrecision(), event.getDeviceId(),
event.getEdgeFlags());
return super.dispatchTouchEvent(evt);
代码示例来源:origin: stackoverflow.com
.getEventTime(), event.getAction(), event.getPointerCount(),
pointerIDs, pointerCoords, event.getMetaState(), event
.getXPrecision(), event.getYPrecision(), event
.getDeviceId(), event.getEdgeFlags(),
event.getSource(), event.getFlags());
代码示例来源:origin: canqihe/TmallSale
private MotionEvent transformEvent(MotionEvent e, int headerPosition) {
if (headerPosition == MATCHED_STICKIED_HEADER) {
return e;
}
long downTime = e.getDownTime();
long eventTime = e.getEventTime();
int action = e.getAction();
int pointerCount = e.getPointerCount();
int[] pointerIds = getPointerIds(e);
MotionEvent.PointerCoords[] pointerCoords = getPointerCoords(e);
int metaState = e.getMetaState();
float xPrecision = e.getXPrecision();
float yPrecision = e.getYPrecision();
int deviceId = e.getDeviceId();
int edgeFlags = e.getEdgeFlags();
int source = e.getSource();
int flags = e.getFlags();
View headerHolder = getChildAt(headerPosition);
for (int i = 0; i < pointerCount; i++) {
pointerCoords[i].y -= headerHolder.getTop();
}
MotionEvent n = MotionEvent.obtain(downTime, eventTime, action,
pointerCount, pointerIds, pointerCoords, metaState, xPrecision,
yPrecision, deviceId, edgeFlags, source, flags);
return n;
}
代码示例来源:origin: GcsSloop/ViewSupport
PointerCoords[] pointerCoords = getPointerCoords(e);
int metaState = e.getMetaState();
float xPrecision = e.getXPrecision();
float yPrecision = e.getYPrecision();
int deviceId = e.getDeviceId();
内容来源于网络,如有侵权,请联系作者删除!