Android Horizontal Scrolling that Snaps to List Items

青春壹個敷衍的年華 提交于 2019-12-24 13:33:58

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/25840405/android-horizontal-scrolling-that-snaps-to-list-items

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!