How to swipe images up or down using the Gallery widget
I have a project for which I have to display some images. Even if the
Gallery widget is deprecated, it seems to be the best choice, since I have
not so much time to spend on it.
I would like to mimic Android's photo gallery and deleting an image when
swiping it up or down (see the screenshots below). I saw another in SO
question that we can detect vertical swipings (see the code below), but I
would like to move the image during the movement, as in Android's photo
gallery.
How could I implement this feature?
public class CustomGallery extends Gallery
{
[...]
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float
velocityX, float velocityY)
{
if (Math.abs(velocityX) > Math.abs(velocityY))
// Moving horizontally
else
// Moving vertically
return super.onFling(e1, e2, velocityX, velocityY);
}
}
NB: I can also accept an answer based on HorizontalScrollView if it
implements the up- or down-swiping feature and if it has center-locking.
!
No comments:
Post a Comment