ICS View.getTop() 不起作用
在我的应用程序中,我使用 onTouchEvent()
int y = (int) event.getY() - myView.getTop();
来获取相对于我的视图触摸位置。
问题是在冰淇淋三明治中 myView.getTop() 总是返回 0。
此处不报告任何更改。
我的应用程序在 SDK 版本 << 的情况下工作正常14.
On my App in the onTouchEvent() I use
int y = (int) event.getY() - myView.getTop();
to get the relative to my view touch position.
The problem is that in Ice Cream Sandwich myView.getTop() always returns 0.
Here doesn't report any changes.
My App is working fine with SDK Version < 14.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
getTop() 报告 View 在其父容器中的 Y 位置。如果 getTop() 返回 0,这意味着您的视图始终位于其父视图的顶部。 event.getY() 已经返回视图坐标系中的位置。
getTop() reports the Y location of a View within its parent container. If getTop() returns 0, this means your view is located all the way at the top of its parent. event.getY() already returns a position in the view's coordinates system.
我想你需要使用
I think you ned to use