本文整理汇总了Java中android.support.v4.view.MotionEventCompat.getAxisValue方法的典型用法代码示例。如果您正苦于以下问题:Java MotionEventCompat.getAxisValue方法的具体用法?Java MotionEventCompat.getAxisValue怎么用?Java MotionEventCompat.getAxisValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.MotionEventCompat
的用法示例。
在下文中一共展示了MotionEventCompat.getAxisValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onGenericMotionEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
public boolean onGenericMotionEvent(MotionEvent event) {
if (!(this.mLayout == null || this.mLayoutFrozen || (MotionEventCompat.getSource(event) & 2) == 0 || event.getAction() != 8)) {
float vScroll;
float hScroll;
if (this.mLayout.canScrollVertically()) {
vScroll = -MotionEventCompat.getAxisValue(event, 9);
} else {
vScroll = 0.0f;
}
if (this.mLayout.canScrollHorizontally()) {
hScroll = MotionEventCompat.getAxisValue(event, 10);
} else {
hScroll = 0.0f;
}
if (!(vScroll == 0.0f && hScroll == 0.0f)) {
float scrollFactor = getScrollFactor();
scrollByInternal((int) (hScroll * scrollFactor), (int) (vScroll * scrollFactor), event);
}
}
return false;
}
示例2: onGenericMotionEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
@Override
@TargetApi(12)
public boolean onGenericMotionEvent(MotionEvent event) {
if ((MotionEventCompat.getSource(event) & InputDevice.SOURCE_CLASS_POINTER) != 0) {
switch (event.getAction()) {
case MotionEvent.ACTION_SCROLL:
// Process scroll wheel movement:
float yDistance = MotionEventCompat.getAxisValue(event, MotionEvent.AXIS_VSCROLL);
vt320 vtBuffer = (vt320) terminalView.bridge.buffer;
boolean mouseReport = vtBuffer.isMouseReportEnabled();
if (mouseReport) {
int row = (int) Math.floor(event.getY() / terminalView.bridge.charHeight);
int col = (int) Math.floor(event.getX() / terminalView.bridge.charWidth);
vtBuffer.mouseWheel(
yDistance > 0,
col,
row,
(event.getMetaState() & KeyEvent.META_CTRL_ON) != 0,
(event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0,
(event.getMetaState() & KeyEvent.META_META_ON) != 0);
return true;
}
}
}
return super.onGenericMotionEvent(event);
}
示例3: onGenericMotionEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
public boolean onGenericMotionEvent(MotionEvent event) {
if (mLayout == null) {
return false;
}
if (mLayoutFrozen) {
return false;
}
if ((MotionEventCompat.getSource(event) & InputDeviceCompat.SOURCE_CLASS_POINTER) != 0) {
if (event.getAction() == MotionEventCompat.ACTION_SCROLL) {
final float vScroll, hScroll;
if (mLayout.canScrollVertically()) {
// Inverse the sign of the vertical scroll to align the scroll orientation
// with AbsListView.
vScroll = -MotionEventCompat
.getAxisValue(event, MotionEventCompat.AXIS_VSCROLL);
} else {
vScroll = 0f;
}
if (mLayout.canScrollHorizontally()) {
hScroll = MotionEventCompat
.getAxisValue(event, MotionEventCompat.AXIS_HSCROLL);
} else {
hScroll = 0f;
}
if (vScroll != 0 || hScroll != 0) {
final float scrollFactor = getScrollFactor();
scrollByInternal((int) (hScroll * scrollFactor),
(int) (vScroll * scrollFactor), event);
}
}
}
return false;
}
示例4: onGenericMotionEvent
import android.support.v4.view.MotionEventCompat; //导入方法依赖的package包/类
public boolean onGenericMotionEvent(MotionEvent event) {
if ((MotionEventCompat.getSource(event) & 2) != 0) {
switch (event.getAction()) {
case 8:
if (!this.mIsBeingDragged) {
float vscroll = MotionEventCompat.getAxisValue(event, 9);
if (vscroll != 0.0f) {
int delta = (int) (getVerticalScrollFactorCompat() * vscroll);
int range = getScrollRange();
int oldScrollY = getScrollY();
int newScrollY = oldScrollY - delta;
if (newScrollY < 0) {
newScrollY = 0;
} else if (newScrollY > range) {
newScrollY = range;
}
if (newScrollY != oldScrollY) {
super.scrollTo(getScrollX(), newScrollY);
return true;
}
}
}
break;
}
}
return false;
}