My application had a bottom navigation bar which has 5 tabs. So according to these tabs, I have 5 fragments When I click on the tab, the fragment changed according to that t
Using ViewPager with FragmentPagerAdapter suits for you in this case.
ViewPager
FragmentPagerAdapter
Then use ViewPager#setOffsetPageLimit(5). This will help you show/hide your fragments without recreating it again.
ViewPager#setOffsetPageLimit(5)
Follow this tutorial
Let try it, then tell me if your problem is solved or not. ;)