View.onTouchEvent only registers ACTION_DOWN event

落爺英雄遲暮 提交于 2019-12-05 12:05:38

问题


I'm implementing a custom TextView and I want to do some action when the view is touched. I figured the onTouchEvent method would give me the full range of touches on the view without having to use setOnTouchListener (I'm trying to do all my work inside the view instead of in the activity so it's portable), but the only touch event registered is ACTION_DOWN. If I set an OnTouchListener in the activity using this, I get the full range of touch events, but onTouchEvent doesn't.

Anyone know why this is the case, or can anyone offer me a solution that doesn't involve using setOnTouchListener (Which would prevent the implementing activity from setting its own listener)?


回答1:


You need to return true to get the following events after a down.



来源:https://stackoverflow.com/questions/6391748/view-ontouchevent-only-registers-action-down-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!