HorizontalScrollView怎么监听滑动方向和禁用滑动
展开全部
重写onTouchEvent,返回false,试一下,
控制方向
.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if(MotionEvent.ACTION_DOWN==event.getAction()){
mPosX = (int)event.getX();
mPosY = (int)event.getY();
}
if (MotionEvent.ACTION_MOVE == event.getAction()) {
mCurrentPosX = (int)event.getX()-mPosX;
mCurrentPosY = (int)event.getY()-mPosY;
mPosX = (int)event.getX();
mPosY = (int)event.getY();
}
if (mCurrentPosX - mPosX > 0 && Math.abs(mCurrentPosY - mPosY) < 10)
{
Log.e("", "向右的按下位置"+mPosX+"移动位置"+mCurrentPosX);
控制方向
.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if(MotionEvent.ACTION_DOWN==event.getAction()){
mPosX = (int)event.getX();
mPosY = (int)event.getY();
}
if (MotionEvent.ACTION_MOVE == event.getAction()) {
mCurrentPosX = (int)event.getX()-mPosX;
mCurrentPosY = (int)event.getY()-mPosY;
mPosX = (int)event.getX();
mPosY = (int)event.getY();
}
if (mCurrentPosX - mPosX > 0 && Math.abs(mCurrentPosY - mPosY) < 10)
{
Log.e("", "向右的按下位置"+mPosX+"移动位置"+mCurrentPosX);
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询