I want to Disable Shift Mode with kotlin, I used material BottomNavigationView
<com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/bottom_navigation" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="bottom" app:itemIconSize="@dimen/iconSize" android:background="?android:attr/windowBackground" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:menu="@menu/btm_nav_menu" app:labelVisibilityMode="labeled" />
I want click account icon and start activity login when click back button homeFragment will be selected not account icon selected
bottom_navigation.setOnNavigationItemSelectedListener { when(it.itemId) { R.id.homeFragment -> showNav(HomeFragment()) R.id.accountFragment -> { bottom_navigation.menu.findItem(R.id.homeFragment).setCheckable(true) startActivity(Intent(this, MainActivity2::class.java)) } } true } fun showNav(fragment: Fragment){ supportFragmentManager.beginTransaction().apply { replace(R.id.fragment_container, fragment) commit() } }
Asked
Active
Viewed 157 times
0
-
Can you explain better *"disable animate when click icon"*? – Gabriele Mariotti Aug 13 '20 at 07:24
-
Disable Shift Mode – TEN_KUNG Aug 13 '20 at 08:33
-
`app:labelVisibilityMode="labeled"` shoud be enough – Gabriele Mariotti Aug 13 '20 at 08:53
-
Nope, Also text and icon bigger when click it, I don't want – TEN_KUNG Aug 13 '20 at 10:46
1 Answers
0
Answer 2. Use false, Bottom Navigation will not select the icon
bottom_navigation.setOnNavigationItemSelectedListener {
when(it.itemId) {
R.id.homeFragment -> {
showNav(HomeFragment())
true
}
R.id.accountFragment -> {
startActivity(Intent(this, MainActivity2::class.java))
false
} else -> true
}
}

TEN_KUNG
- 1,229
- 2
- 5
- 12