How to make an Android view that flips between views on swipe/fling

后端 未结 4 1716
梦如初夏
梦如初夏 2020-11-28 23:01

I\'d like to make a view in my Android app that flips between multiple views on a swipe/fling. I\'d like it to behave more or less like the Android Launcher behaves when fl

相关标签:
4条回答
  • 2020-11-28 23:29

    Check out SwipeView within this project https://github.com/fry15/uk.co.jasonfry.android.tools It does exactly what you want it to do and is super simple to implement.

    0 讨论(0)
  • 2020-11-28 23:29

    @CommonsGuy extended ViewFlipper to do it. https://github.com/commonsguy/cwac-viewswiper Ihaven't used this one yet so im not sure if it moves with your finger like the launcher if not your going to have to make an OnTochListener to do it for you in me.ACTION_MOVE you will update the view to change its position. I'll post some sample code when I get home if you don't get another answer.

    0 讨论(0)
  • 2020-11-28 23:33

    Take a look at HorizontalPager. It's actually based on RealViewSwitcher, which in turn is based on the Android homescreen's code, and supports snap-to paging with drag feedback, as well as nested vertically-scrolling subviews. Gesture support for fast swipes isn't all it should be, but this may get you part of the way there (and I'd welcome contributions back).

    EDIT: As of 2012 you're much better off using Google's ViewPager - it's in the compat library.

    0 讨论(0)
  • 2020-11-28 23:37

    I know this is an old question but ViewPager is created for this exact same purpose. ViewPager is part of android compatibility package and more can be found at http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html

    0 讨论(0)
提交回复
热议问题