-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 –