Bottombar: How does it work with viewpager?

Created on 17 Mar 2016  路  3Comments  路  Source: roughike/BottomBar

enhancement wontfix

Most helpful comment

It doesn't at this time. I'll look into it and see if it should / can be done.

It seems that this is not meant to be an indicator for ViewPager though:

Using swipe gestures on the content area does not navigate between views.
Avoid using lateral motion to transition between views.

All 3 comments

It doesn't at this time. I'll look into it and see if it should / can be done.

It seems that this is not meant to be an indicator for ViewPager though:

Using swipe gestures on the content area does not navigate between views.
Avoid using lateral motion to transition between views.

I won't make this a ViewPager indicator for now.

What you want can easily be implemented (but the guidelines discourage doing it) by adding OnPageChangeListener to your ViewPager and selecting tabs manually:

ViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
    @Override
    public void onPageSelected(int position) {
        // select a new tab and animate the selection.
        bottomBar.selectTabAtPosition(position, true);
    }
});

Avoid recursion by adding condition check.

mViewer.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                // select a new tab and animate the selection.
                 if(position != mBottomBar.getCurrentTabPosition())
                mBottomBar.selectTabAtPosition(position, true);
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
Was this page helpful?
0 / 5 - 0 ratings

Related issues

cmonfortep picture cmonfortep  路  5Comments

yerenutku picture yerenutku  路  4Comments

BlaineOmega picture BlaineOmega  路  7Comments

vikramkakkar picture vikramkakkar  路  3Comments

zhangzhzh picture zhangzhzh  路  7Comments