Question

I am on a project that need to use a gallery view in it. If you will build the HelloGallery project from developer.android site (The Default Android Example of Gallery) it will work great.

Issue is

if you will scroll the gallery with a fast swipe. it will move so quick that the last image comes to front.

How can I control this horizontal scrolling rate and make any swipe move to next/previous image only?

This will be bad to read touch events of gallery and reading left or right swipe over the view and setting the next or previous image to front.

Was it helpful?

Solution

If you extend the Gallery View, you'll be able to override the touch events and stop a 'fling' from occurring, then you just need to handle the swipe to move one position left or right.

OTHER TIPS

extending the Gallery class overriding the onFling Method with this code will solve and allow us to give any horrizontal scroll rate we want

 @Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
        float velocityY) {
    // TODO Auto-generated method stub
    super.onFling(e1, e2, 5, velocityY);
    return false;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top