OzoneX
OzoneX

Reputation: 93

How to set the start default fragment of Bottom Navigation Bar to the center/middle fragment?

I am implementing the following GitHub repo in my project. https://github.com/jaisonfdo/BottomNavigation I didn't paste my code here because I have other features in my project which are not important to the question. This repo is implementing a bottom navigation bar along pageViewer so that we can change the fragments with swipe left/right.

Now the issue is, I want the default/initial screen to be the middle tab and the 2nd fragment. I tried changing the "android:checked" of the second tab to be "true", still at the start, I am getting the 1st tab as default. I also tried changing the order in which the fragments are added initially but still, I am getting the first one as default. The picture is attached below. I want the "CHATS" to be displayed as pink and show the "ChatsFragment" in place of "ContactsFragments".

I want it in middle due to the UI requirements. Any help would be highly appreciated. 1

[enter image description here]

Upvotes: 0

Views: 1858

Answers (1)

Munir
Munir

Reputation: 2558

I see the code at git repo you just need to set the viewpager item. try this code on setupViewPager() method after setting viewpager adapter

 viewPager.setCurrentItem(1);

Upvotes: 1

Related Questions