-1
我正在为一个View
设置动画,显示是否向上滑动,如果向下滑动,则隐藏。 问题是只有在滑动时才能工作。如果我滑下来,视图会随着手指一起移动,但是当我释放触摸时,它会再次上升。onTouchListener Action_Down无法正常工作
这里是我用于动画&幻灯片的代码。
v.setY(480);
v.setVisibility(View.VISIBLE);
v.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
int action = MotionEventCompat.getActionMasked(event);
if (action == MotionEvent.ACTION_DOWN){
v.animate().translationY(480);
return true;
} else if (action == MotionEvent.ACTION_UP) {
v.animate().translationY(0);
return true;
}
return true;
}
});
我在想什么?
访问此链接可能会帮助您https://github.com/codepath/android_guides/wiki/Gestures-and-Touch-Events –