捕捉到列表项目的Android水平滚动 [英] Android Horizontal Scrolling that Snaps to List Items

查看:83
本文介绍了捕捉到列表项目的Android水平滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Android中实现用户可以查看单个项目的UI体验(例如,我的案例中的项目是文本集合),然后在项目上向左或向右滑动即可转到上一个或下一个项目。

在我的研究中,ListView没有实现水平滚动。潜在的候选人似乎是Horizo​​ntalScrollView和GridView,但我还没有看到任何可以做到这一点的例子 - 只需要包含看起来很复杂的库。



我的问题是,有没有一种方法可以使用ListView,Horizo​​ntalScrollView,GridView或它们的组合来实现水平滚动,一次显示一个项目并捕捉显示的项目?



下图中突出显示的区域显示了我试图实现此逻辑的位置。



解决方案

实现这种体验的最佳选择是ViewPager,它需要android支持库。



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


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.

From my research, ListView does not implement horizontal scrolling. 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.

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?

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.

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

这篇关于捕捉到列表项目的Android水平滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆