Skip to content

Request: add support for case where multiple items visible #5

Open

Description

@stevep99

It is possible to use ViewPager to create a "carousel" effect, by having multiple items visible at the same time . This is typically done by setting e.g. ViewPager.setOffscreenPageLimit(3) and setting some appropriate margins.

In this mode, LoopingViewPager no longer works correctly at the transition between first and last items. This is because LoopViewPager has an internal fixed offset of 1 item, so if any more than one item is visible at once, these will not be shown correctly.

This can be fixed by allowing an arbitrary offset value to be set and changing the various hardcoded 1s to the new value, for example:

    public static int toRealPosition( int position, int count ){
        position = position-OFFSET;
        if( position < 0 ){
            position += count;
        }else{
            position = position%count;
        }
        return position;
    }

I have this working in my case, can send patch if interested.

Activity

  1. thalisvilela commented on Jul 3, 2014

    @thalisvilela

    stevepugh99, i'm facing the same issue. Managed to archieve the carousel effect and it works just fine, the only issue is the lag when changing between first and last items. Can you give me more info and help me implement your solution? Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions