Open LassassinX opened 4 years ago
You can check the following code out for inspiration.
mainViewPager.addOnPageChangeListener(object : OnPageChangeListener {
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
override fun onPageSelected(position: Int) {
bottomBar.setActiveItem(position)
}
override fun onPageScrollStateChanged(state: Int) {}
})
bottomBar.onItemSelected = { i: Int -> mainViewPager.currentItem = i }
Integration in the lib itself like the TabLayout
might be interesting to do. But the above works well for now.
That is great! Can I get an example in java ? I'm pretty new
Okay so I've implemented this. However, the responsiveness is not good. The tab items change way after the viewpager has set a page, making it look very unresponsive. Will this feature be integrated into the library soon so that the animation is smoother ? TIA
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
smoothBottomBar.setItemActiveIndex(position);
}
Anyway to set this bottom bar with a viewpager ? So that I can swipe back and forth between fragments ?