Skip to content

WoWoViewPager Attributes

Weiping Huang edited this page Apr 6, 2017 · 3 revisions

Gearbox

You may notice that the scrolling speed of WoWoViewPager is a little bit slower than ViewPager. Because the scroller of WoWoViewPager is override and Gearbox is used to controller the speed. There are several gearboxes provided in WoWoGearbox, in which WoWoGearbox.Positive5 is the original speed of ViewPager and WoWoGearbox.Positive3 is the default speed of WoWoViewPager. The gearbox is able to changed by setGearbox method of WoWoViewPager:

wowo.setGearbox(WoWoGearbox.Gearboxes[progress]);

Try to adjust the gearbox of WoWoViewPager in the demo activity to find the most suitable speed of WoWoViewPager. As a matter of fact, gearbox is a kind of Interpolator. Yon can define you own gearbox by:

wowo.setGearbox(new Gearbox() {
    @Override
    public float getInterpolation(float input) {
        return input;
    }
});

Static

Sometimes you may want WoWoViewPager to be undraggable:

wowo.setDraggable(false);

When the WoWoViewPager is undraggable, you can call wowo.next() to scroll WoWoViewPager to next page and wowo.previous() on the contrary. The duration of scrolling is able to changed:

wowo.setScrollDuration(1000);

Check the demo activity for more details.

Auto Scroll

WoWoViewPager supports automatical scrolling by the method:

/**
 * Start scroll automatically.
 *
 * @param touchThenStop If WoWoViewPager is touched, then stop scrolling automatically.
 * @param delayPerPage Delay before scrolling for each page.
 * @param scrollDuration Scroll-duration for each page.
 */
startAutoScroll(boolean touchThenStop, int delayPerPage, int scrollDuration);

And you should remember to stop the automatical scrolling:

wowo.stopAutoScroll();

Check the demo activity for more information.

Direction

WoWoViewPager is able to scroll vertically:

if (wowo.getDirection() == WoWoViewPager.Horizontal) {
    wowo.setDirection(WoWoViewPager.Vertical);
} else {
    wowo.setDirection(WoWoViewPager.Horizontal);
}

Try the demo activity for vertical scrolling.

.xml

You can set the above attributes in .xml file:

<com.nightonke.wowoviewpager.WoWoViewPager
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:wowo_gearbox="positive1"
    app:wowo_draggable="false"
    app:wowo_scrollDuration="2000"
    app:wowo_direction="vertical"
    />