Skip to content Skip to sidebar Skip to footer

Next And Previous Image By Swipe S

i am new in android and working a comic application. i am using this code visit https://github.com/sephiroth74/ImageViewZoom for pinch zoom . and working it very fine. but i am t

Solution 1:

You can detect fling gestures on your main view like this:

finalGestureDetectordetector=newGestureDetector(newGestureDetector.SimpleOnGestureListener() {
    @OverridepublicbooleanonFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        if(velocityX > 0) {
            selectnextImage();
        }
        else {
            selectpreImage();
        }
        returntrue;
    }
});

view.setOnTouchListener(newOnTouchListener() {
    @OverridepublicbooleanonTouch(View v, MotionEvent event) {
        if(event.getPointerCount() == 1) {
            if(mimage.getScale() == 1f) {
                detector.onTouchEvent(event);
                returntrue;
            }
            else {
                returnfalse;
            }
        }
        else {
            returnfalse;
        }
    }
});

Solution 2:

Try looking at the Android documentation for Implementing Lateral Navigation. This uses a ViewPager. I believe this is what Google recommends for something like this. You may not want to have the tabs there, but you can implement it without tabs. You can also implement it with a FragmentPagerAdapter.

Post a Comment for "Next And Previous Image By Swipe S"