Reputation: 1030
I did so much researches in the internet and the conclusion was that we cannot use BottomNavigationView
and ViewPager
and TabLayout
simultaneously. but there are a lot of app such as Instagram that merged them.
my question is that how can they do that? do they use a special trick or not?
Upvotes: 3
Views: 336
Reputation: 36
you can create bottomNavigationView in activity and attach fragment in it with this code when click a on item of it:
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction()
.replace(frameId, fragment, "fragTransaction");
transaction.commit();
and then create a fragment wiht a tabLayout and viewPager to control child fragment in it and you most using to control fragment in viewPagerAdapter
FragmentManager fragmentManager = getChildFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction()
.replace(frameId, fragment, "fragTransaction");
transaction.commit();
Upvotes: 1
Reputation: 2937
It is not difficult to use bottomNavigationView with ViewPager.
Do you need more detailed code examples, or you are ready to rock?
Upvotes: 1