Android horizontal scrollview behave like iPhone (paging)

前端 未结 4 921
星月不相逢
星月不相逢 2020-12-02 06:15

I have a LinearLayout inside a HorizontalScrollView. The content is just a image. While scrolling, I need to achieve the same behavior you get when setting the paging option

4条回答
  •  爱一瞬间的悲伤
    2020-12-02 06:54

    I came across a nice solution here:

    Horizontal Pager

    this is a cleaned up GitHub version of the code found here:

    Real View Switcher

    It may seem like overkill for just using it on images, but this solution allows for infinite paging with using a little trick (ie: when on first page you can scroll back to last page and when on last page you can scroll forward to first page). It also allows you to have an unknown number of pages and dynamically generate content by using another little trick. Please see my comment in the second link here

    for details on how i accomplished this.

    Hope this helps.

提交回复
热议问题