Search code examples
androidkotlinmenuitemcheckedbottomnavigationview

Kotlin - BottomNavigationView uncheck all items


I got a problem on unckeck all items in bottom navigation. I've tried multiple codes, for exemple:

 val bottomNavigationView: BottomNavigationView
 bottomNavigationView = conteudo_feridas.findViewById<BottomNavigationView>(R.id.nav_bottom_cartao_tipo) as BottomNavigationView

 val size = bottomNavigationView.menu.size()
 for (i in 0 until size) {
     bottomNavigationView.menu.getItem(i).isChecked = false
 }

Nothing works. I want all the items to have the same size, and in the default case, the checked one gets bigger. I'm trying to reach the following effect:

enter image description here

Can you help me, please?

Thank you very much.


Solution

  • in your dimen.xml just add below two line

    <dimen name="design_bottom_navigation_text_size" tools:override="true">14sp</dimen>
    <dimen name="design_bottom_navigation_active_text_size" tools:override="true">14sp</dimen>
    

    it will work exactly you want

    you can change size according to your requirement

    If you give the same size it will appear same in selected and nonselected item