Detect swipe right/ left in Fragments?

665 Views Asked by At

i have a viewpager application working with three fragments´(left, mid, right). When i swipe from the mid fragment to the left fragment i want an animation to start in the left fragment.

Is there any way i can detect this gesture and implement functionality to it easily? If you need my code tell me, but i think this expanation should suit any needs of understanding what im trying to do.

Thanks!

1

There are 1 best solutions below

0
On

You can use ViewPager.OnPageChangeListener which has the methods:

public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels)
public void onPageSelected(int position)

and decide what you need.

Alternatively, have a look at ViewPager.PageTransformer