本文整理了Java中android.view.MotionEvent.getSize()
方法的一些代码示例,展示了MotionEvent.getSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MotionEvent.getSize()
方法的具体详情如下:
包路径:android.view.MotionEvent
类名称:MotionEvent
方法名:getSize
暂无
代码示例来源:origin: robolectric/robolectric
.isWithin(tolerance)
.of(other.getPressure());
check("getSize()").that(actual().getSize()).isWithin(tolerance).of(other.getSize());
check("getTouchMajor()")
.that(actual().getTouchMajor())
.isWithin(tolerance)
.of(other.getPressure(i));
check("getSize(%s)", i).that(actual().getSize(i)).isWithin(tolerance).of(other.getSize(i));
check("getTouchMajor(%s)", i)
.that(actual().getTouchMajor(i))
代码示例来源:origin: stackoverflow.com
@Override
public boolean onTouchEvent(MotionEvent event) {
int largestIndex, largestSize=0; //holds largest point data
for(int i=0; i<event.getPointerCount(); i++){ //loop through each touch point
if(event.getSize(i) > largestSize){ //if this size is greater than the previous largest one
//store the new size and pointer index
largestSize = event.getSize(i);
largestIndex = i;
}
}
//work with the largest touch point here
//you can change this to return true if you're always handling the touchevent completly yourself
return super.onTouchEvent(event);
}
代码示例来源:origin: stackoverflow.com
myImageButton.setOnTouchListener(new Button.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent arg1) {
if (arg1.getAction() == android.view.MotionEvent.ACTION_DOWN
&& (arg1.getSize() > 1) {
Toast.makeText(LiVoiceActivity.this,
"You touched me!",
Toast.LENGTH_LONG).show();
}
return true;
}
});
代码示例来源:origin: stackoverflow.com
@Override
public boolean onTouchEvent(MotionEvent event) {
switch(event.getAction())
{
case MotionEvent.ACTION_MOVE:
System.out.println(event.getPressure());
System.out.println(event.getSize());
break;
}
return true;
代码示例来源:origin: luhaoaimama1/zone-sdk
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
int dis = (int) distanceX;
Log.i(TAG,"dis"+ dis );
if(e1!=null){
System.err.println("e1X:"+e1.getX());
}
if(e2!=null){
System.err.println("e2X:"+e2.getX()+"\te2History"+e2.getSize());
}
if (first&&e1==null) {
first=false;
}else{
smoothScrollBy(dis, 0);
}
return false;
}
代码示例来源:origin: luhaoaimama1/zone-sdk
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
int dis = (int) distanceX;
Log.i(TAG, "dis" + dis);
if (e1 != null) {
System.err.println("e1X:" + e1.getX());
}
if (e2 != null) {
System.err.println("e2X:" + e2.getX() + "\te2History" + e2.getSize());
}
if (first && e1 == null) {
first = false;
} else {
smoothScrollBy(dis, 0);
}
return false;
}
代码示例来源:origin: luhaoaimama1/zone-sdk
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
int dis = (int) distanceX;
// Log.i(TAG,"dis"+ dis );
System.err.println(TAG + "____________________disX:" + distanceX);
if (e1 != null) {
System.err.println("e1X:" + e1.getX());
} else {
System.err.println("e1:" + null);
}
if (e2 != null) {
System.err.println("e2X:" + e2.getX() + "\te2History" + e2.getSize());
} else {
System.err.println("e2:" + null);
}
if (first && e1 == null) {
first = false;
} else {
smoothScrollBy(dis, 0);
System.err.println("smoothScrollBy _______dis:" + dis);
}
return false;
}
代码示例来源:origin: Unity-Technologies/unity-ads-android
@TargetApi(14)
public boolean onInterceptTouchEvent(MotionEvent e) {
super.onInterceptTouchEvent(e);
if (_shouldCapture) {
if (_motionEvents.size() < _maxEvents) {
boolean isObscured = (e.getFlags() & MotionEvent.FLAG_WINDOW_IS_OBSCURED) != 0;
synchronized (_motionEvents) {
_motionEvents.add(new AdUnitMotionEvent(e.getActionMasked(), isObscured, e.getToolType(0), e.getSource(), e.getDeviceId(), e.getX(0), e.getY(0), e.getEventTime(), e.getPressure(0), e.getSize(0)));
}
}
}
return false;
}
代码示例来源:origin: stackoverflow.com
xTouch[pointerId] = event.getX(i);
yTouch[pointerId] = event.getY(i);
float siz = event.getSize(i);
代码示例来源:origin: playn/playn
private Touch.Event[] parseMotionEvent (MotionEvent event, Touch.Event.Kind kind) {
int actionType = event.getActionMasked();
boolean isChanged = (actionType == MotionEvent.ACTION_POINTER_UP ||
actionType == MotionEvent.ACTION_POINTER_DOWN);
int changedIdx = isChanged ? event.getActionIndex() : 0;
int count = event.getPointerCount();
Touch.Event[] touches = new Touch.Event[isChanged ? 1 : count];
double time = event.getEventTime();
int tidx = 0;
for (int tt = 0; tt < count; tt++) {
// if this is a pointer up/down, we only want the changed touch
if (isChanged && tt != changedIdx) continue;
IPoint xy = plat.graphics().transformTouch(event.getX(tt), event.getY(tt));
float pressure = event.getPressure(tt);
float size = event.getSize(tt);
int id = event.getPointerId(tt)+1;
touches[tidx++] = new Touch.Event(0, time, xy.x(), xy.y(), kind, id, pressure, size);
}
return touches;
}
代码示例来源:origin: threerings/playn
/**
* Performs the actual parsing of the MotionEvent event.
*
* @param event The MotionEvent to process
* @param preventDefault Shared preventDefault state among returned {@link AndroidTouchEventImpl}
* @return Processed array of {@link AndroidTouchEventImpl}s which share a preventDefault state.
*/
private Touch.Event.Impl[] parseMotionEvent(MotionEvent event, Events.Flags flags) {
int eventPointerCount = event.getPointerCount();
Touch.Event.Impl[] touches = new Touch.Event.Impl[eventPointerCount];
double time = event.getEventTime();
float pressure, size;
int id;
for (int t = 0; t < eventPointerCount; t++) {
int pointerIndex = t;
IPoint xy = platform.graphics().transformTouch(
event.getX(pointerIndex), event.getY(pointerIndex));
pressure = event.getPressure(pointerIndex);
size = event.getSize(pointerIndex);
id = event.getPointerId(pointerIndex);
touches[t] = new Touch.Event.Impl(flags, time, xy.x(), xy.y(), id, pressure, size);
}
return touches;
}
}
代码示例来源:origin: com.googlecode.playn/playn-android
/**
* Performs the actual parsing of the MotionEvent event.
*
* @param event The MotionEvent to process
* @param preventDefault Shared preventDefault state among returned {@link AndroidTouchEventImpl}
* @return Processed array of {@link AndroidTouchEventImpl}s which share a preventDefault state.
*/
private Touch.Event.Impl[] parseMotionEvent(MotionEvent event, Events.Flags flags) {
int eventPointerCount = event.getPointerCount();
Touch.Event.Impl[] touches = new Touch.Event.Impl[eventPointerCount];
double time = event.getEventTime();
float pressure, size;
int id;
for (int t = 0; t < eventPointerCount; t++) {
int pointerIndex = t;
IPoint xy = platform.graphics().transformTouch(
event.getX(pointerIndex), event.getY(pointerIndex));
pressure = event.getPressure(pointerIndex);
size = event.getSize(pointerIndex);
id = event.getPointerId(pointerIndex);
touches[t] = new Touch.Event.Impl(flags, time, xy.x(), xy.y(), id, pressure, size);
}
return touches;
}
}
代码示例来源:origin: stackoverflow.com
adjustCoords(coords, getRotation());
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());
代码示例来源:origin: stackoverflow.com
xTouch[pointerId] = event.getX(i);
yTouch[pointerId] = event.getY(i);
float siz = event.getSize(i);
代码示例来源:origin: stackoverflow.com
MotionEvent verticalEvent = MotionEvent
.obtain(event.getDownTime(), event.getEventTime(), event.getAction(), x, y,
event.getPressure(), event.getSize(), event.getMetaState(),
event.getYPrecision(), event.getXPrecision(), event.getDeviceId(),
event.getEdgeFlags());
代码示例来源:origin: stackoverflow.com
adjustCoords(coords, -getRotation());
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());
代码示例来源:origin: stackoverflow.com
adjustCoords(coords, getRotation());
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());
代码示例来源:origin: stackoverflow.com
adjustCoords(coords, -mHeading);
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());
代码示例来源:origin: stackoverflow.com
@Override public boolean onTouchEvent(MotionEvent event) {
int action = event.getAction();
mCurDown = action == MotionEvent.ACTION_DOWN
|| action == MotionEvent.ACTION_MOVE;
int N = event.getHistorySize();
for (int i=0; i<N; i++) {
drawPoint(event.getHistoricalX(i), event.getHistoricalY(i),
event.getHistoricalPressure(i),
event.getHistoricalSize(i));
}
drawPoint(event.getX(), event.getY(), event.getPressure(),
event.getSize());
return true;
}
private void drawPoint(float x, float y, float pressure, float size) {
mCurX = (int)x;
mCurY = (int)y;
mCurPressure = pressure;
mCurSize = size;
mCurWidth = (int)(mCurSize*(getWidth()/3));
if (mCurWidth < 1) mCurWidth = 1;
if (mCurDown && mBitmap != null) {
int pressureLevel = (int)(mCurPressure*255);
mPaint.setARGB(pressureLevel, 255, 255, 255);
mCanvas.drawCircle(mCurX, mCurY, mCurWidth, mPaint);
mRect.set(mCurX-mCurWidth-2, mCurY-mCurWidth-2,
mCurX+mCurWidth+2, mCurY+mCurWidth+2);
invalidate(mRect);
}
}
代码示例来源:origin: stackoverflow.com
event.getSize());
return true;
内容来源于网络,如有侵权,请联系作者删除!