简体   繁体   English

捕捉到列表项的Android水平滚动

[英]Android Horizontal Scrolling that Snaps to List Items

I'd like to implement a UI experience in Android where a user can view a single item (for example, an item in my case is a collection of texts), and swipe left or right on the item to go to the previous or next item. 我想在Android中实现UI体验,用户可以查看单个项目(例如,在我的情况下,一个项目是一组文本),然后在该项目上向左或向右滑动即可转到上一个或下一个项目。

From my research, ListView does not implement horizontal scrolling. 根据我的研究,ListView没有实现水平滚动。 Potential candidates seem to be HorizontalScrollView and GridView, but I haven't seen any examples that can do this simply - only seemingly complicated libraries that need to be included. 潜在的候选对象似乎是Horizo​​ntalScrollView和GridView,但我还没有看到任何可以简单地实现此目的的示例-仅需要包含看似复杂的库。

My question is, is there a way to use ListView, HorizontalScrollView, GridView, or a combination of them to implement a horizontal scroll that shows one item at a time and snaps to the item being displayed? 我的问题是,有没有一种方法可以使用ListView,Horizo​​ntalScrollView,GridView或它们的组合来实现水平滚动,一次显示一个项目并捕捉到所显示的项目?

The highlighted area in the picture below shows where I'm trying to implement this logic. 下图中突出显示的区域显示了我正在尝试实现此逻辑的位置。

水平滚动

It looks like the best option to achieve this experience is a ViewPager, which requires the android support library. 看来,要获得这种体验的最佳选择是ViewPager,它需要android支持库。

http://developer.android.com/reference/android/support/v4/view/ViewPager.html http://developer.android.com/reference/android/support/v4/view/ViewPager.html

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

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