- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
只是一个确认文档的快速问题:
getY(int) function from MotionEvent在 Android 中,它的文档让我感到困惑:
Returns the Y coordinate of this event for the given pointer index (use getPointerId(int) to find the pointer identifier for this index). Whole numbers are pixels; the value may have a fraction for input devices that are sub-pixel precise.
有了这个,我认为代码应该这样写:
for(int i = 0; i < event.getPointerCount(); ++i) {
// Some code...
int currentPointer = event.getPointerId(i);
float currentY = event.getY(currentPointer);
Log.i("test", "Pointer " + currentPointer + " has Y-coord of " + currentY);
// Some more code ...
}
但是,在我的 Samsung Galaxy Tab 上进行测试时,我似乎不应该将 currentPointer 传递给 getY,而应该像这样传递 'i':
for(int i = 0; i < event.getPointerCount(); ++i) {
// Some code...
int currentPointer = event.getPointerId(i);
float currentY = event.getY(i);
Log.i("test", "Pointer " + currentPointer + " has Y-coord of " + currentY);
// Some more code ...
}
这是使用 getPointerId 和 getY 函数的正确方法吗?你给他们两个相同的'i'变量而不是他们的实际指针ID?
我问是因为我想确保这在我的设备上没有什么不同,这确实是它的预期工作方式。谢谢。
最佳答案
是的,这是正确的,您应该只指定“i”。
所有 getPointer*(int) 方法都采用相同的索引作为参数。
关于安卓 MotionEvent getY(int) : Which call is the correct way?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7913533/
我正在尝试计算 WriteHTMLCell 框的高度。我想我可以使用调用 WriteHTMLCell() 前后 Y 位置之间的差异.... $start_y = $pdf->GetY(); $p
当我按窗口左上角附近的某个位置时,由于某种原因,输出结果为 e.getY()比 e.getX() 高约 40 。我不明白为什么...你呢?我对 e.getY() 不太清楚. //BBDemo.java
这是一个很长的问题。我已尽力使其更加简洁,但我认为您需要所有信息来提供帮助。 总结如下:我正在 try catch 连续点击作为端点。我将在这些点之间绘制 line2D 对象。我有一个监听器,它将点击
我在 JFrame 中嵌入了一个 JPanel。 JPanel被添加到BorderLayout的CENTER。我正在使用以下代码对其进行绘制,但 MouseEvent 的 getX() 和 getY(
我在 LibGDX 中遇到一个问题,当我调用 Gdx.input.getY() 时,它会选择一个位于应用程序相对于屏幕中心另一侧的像素。 public class Main extends Appli
好吧,我没什么可说的,但基本上我有一个 Player 类,然后在 GFX 类中我用它绘制 Player他的 getX() 和 getY() 所以 player.getX() 正如你所看到的,我制作了
这个问题在这里已经有了答案: Android ACTION_MOVE Threshold (3 个答案) 关闭 8 年前。 当读取一系列 onTouch 事件的 getX() 和 getY() 值时
我试图通过 onClickListener() 使一个 ImageView 移动到另一个 ImageView 的相同位置,我可以返回 x 但不能返回 y。 我要复制的 View 位置在 xml 中是不
GUI 组件的位置、宽度和高度何时设置?如果使用布局管理器,这些字段会受到怎样的影响?我有一个包含两个 slider 的面板,我想在其中一个 slider 旁边绘制一个矩形。下面是我的代码,用于初始化
在我解释文档时,getY()应该返回矩形的左上角 Y 坐标;即最大的Y坐标。但是,当调用 getMaxY() (继承自 RectangularShape 类)我得到了一个更大的值! 在代码中: Pat
我似乎不太了解 android View 中 getTop() 和 getY() 之间的区别。它们有何不同? 最佳答案 getTop() 返回相对于父级的 y 坐标。 getY() 像 getTop(
我正在尝试制作一个简单的应用程序,以便更好地了解如何在 Android 上使用触摸事件。现在,我的 Activity 只是将 ImageView 移动到屏幕上触摸的坐标(MotionEvent 的坐标
我需要帮助来理解以下内容。 假设我有一个 854x480 像素的显示器。为什么 MotionEvent.getX 和 getY 方法返回 float ?据我所知,显示器上的像素是离散整数,显示器上没有
有很多关于 MotionEvent.getX/.getY 如何“不可靠”(或其他术语)以及我们应该使用这些调用的原始版本来获取坐标的讨论。 在我的 Nexus 7 上,我发现 .getX/.getY
我有两个 ImageView。我想将一个移动到另一个之上。 当我尝试检索 ImageView 位置之一的值以将另一个移动到它时,我在 x 和 y 上都得到 0。 我尝试使用 getLeft/getTo
我正在编写一个基本的绘画程序,但我在 Rectangle 方面遇到了麻烦。和Ellipse工具。如果单击并拖动,您应该能够根据 startpoint 绘制尺寸的形状。和endpoint (都使用 ge
这是一项更大的家庭作业。如何使用 getX() 和 getY() 绘制一条线?这是我的代码,请帮忙。 package shapes; import java.awt.Color; import jav
我正在尝试创建一种方法来计算两个 Point 对象之间的距离: public class Point { private double x; private double y;
我有以下情况: 我有一个带有 ImageView 和 TextView 的自定义 ListView。ImageView 有一个 onTouchListener,它调用我的 onTouch 方法。以下是
本文整理了Java中us.ihmc.yoVariables.variable.YoFrameVector3D.getY()方法的一些代码示例,展示了YoFrameVector3D.getY()的具体用
我是一名优秀的程序员,十分优秀!