View Pager circular indicator to custom View Pager

3.2k views Asked by At

I am using this Vertical View Pager in one of my app. This view pager scrolls vertically instead of traditional view pager which scrolls horizontally.

I want to show View Pager indicator in this View Pager. I came across this View Pager Indicator library to show indicator to the view pager.

Below is my xml code:

<RelativeLayout
            android:id="@+id/scroll_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="visible">

            <com.viewpagerindicator.CirclePageIndicator
                android:id="@+id/view_pager_indicator"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="10dip" />

            <fr.castorflex.android.verticalviewpager.VerticalViewPager
                android:id="@+id/view_pager"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>

        </RelativeLayout>

Below is my activity code to attach view pager with the view pager indicator

mViewPager = (VerticalViewPager) findViewById(R.id.view_pager);
mViewPagerIndicator = (CirclePageIndicator) findViewById(R.id.view_pager_indicator);
mViewPagerIndicator.setViewPager(mVerticalViewPager); //need to pass the object of support v4 ViewPager

The third line in the above code gives error. This is because the setViewPager() method takes android.support.v4.view.ViewPager as parameter and I am sending object of VerticalViewPager.

How can I send the Object this CustomViewPager? How can I view pager indicator to this CustomViewPager?

Please help me out.

1

There are 1 answers

0
BrantApps On

I have adapted (forked) Jake Wharton's ViewPagerIndicator library to permit vertical and horizontal view paging (with indicator) as can be seen in my application's listing here.

My forked library found here will achieve the effect you require.