禁用 Android 中的部分触摸屏
因此,我试图使用此功能在短时间内禁用我正在制作的应用程序的屏幕,
@Override
public boolean onTouchEvent(MotionEvent pMotioneEvent) {
if(pMotioneEvent.getY() < TestSprite.getY()){
return false;
}else{
return true;
}
}
但这似乎没有效果。我查了一下,一般来说禁用触摸屏似乎是个坏主意,但我仍然很好奇是否有办法。 谢谢
So I was trying to disable the screen for an app I am making for a brief period using this
@Override
public boolean onTouchEvent(MotionEvent pMotioneEvent) {
if(pMotioneEvent.getY() < TestSprite.getY()){
return false;
}else{
return true;
}
}
but this seems to have no effect. I read around and it seems like in general its a bad idea to disable the touch screen, but I'm still curious to know if there is a way.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试
requestDisallowInterceptTouchEvent
You could try
requestDisallowInterceptTouchEvent
如果您想检查屏幕某个区域的触摸事件,您可能需要将其放入视图中并为其设置触摸事件侦听器。
If you want to check for touchevents in a certain area of your screen, you might want to put this in a View and set a touchEvent Listener to it.