In my app I want that when the user Swipes from Bottom to Top the alpha of ImageView
should decrease till a certain point, also if the user Swipes from Top to Bottom the alpha should increase till 1. I tried many things still no success
Code
gestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener());
GestureDetector.SimpleOnGestureListener simpleOnGestureListener = new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
float distanceX = 0;
float distanceY = 0;
try {
distanceX = e2.getX() - e1.getX();
distanceY = e2.getY() - e1.getY();
} catch (Exception e) {
}
if (Math.abs(distanceY) > Math.abs(distanceX) && Math.abs(distanceY) > THRESHOLD && Math.abs(velocityY) > VELOCITY) {
if (distanceY > 0) {
//increase the alpha
} else {
//reduce the alpha
}
return true;
}
return false;
}
};
gestureDetector = new GestureDetector(this, simpleOnGestureListener);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
return gestureDetector.onTouchEvent(event);
}