简体   繁体   English

检测到片段中向右/向左滑动?

[英]Detect swipe right/ left in Fragments?

i have a viewpager application working with three fragments ´( left, mid, right ). 我有一个viewpager应用程序,它处理三个fragments ´( 左,中,右 )。 When i swipe from the mid fragment to the left fragment i want an animation to start in the left fragment . 当我从中间 fragment 向左 fragment滑动时,我希望动画从左 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! 谢谢!

You can use ViewPager.OnPageChangeListener which has the methods: 您可以使用具有以下方法的ViewPager.OnPageChangeListener

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 另外,看看ViewPager.PageTransformer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM