skip to Main Content
    <com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/bottomAppBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/primary"
    app:itemIconSize="20dp"
    app:itemTextAppearanceActive="@style/BottomNavigationView.Active"
    app:itemTextAppearanceInactive="@style/BottomNavigationView.Inactive"
    android:layout_alignParentBottom="true"
    app:menu="@menu/bottom_menu"/>

enter image description here

i am expecting default height of the bottom navigation view.

2

Answers


  1. I don’t know if it is the solution that you are waiting, but I solved this deleting next piece of code on my Activity.kt:

    enableEdgeToEdge()
    

    and

        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
    

    Another way is changing

    setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
    

    for

    setPadding(systemBars.left, systemBars.top, systemBars.right, 0)
    
    Login or Signup to reply.
  2. If you are using this in an Activity then,

    remove these following lines form the onCreate() method,

    ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
    val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
    v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
    insets
    }

    And Add this following lines

    ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
    val params = binding.bottomNavigationView.layoutParams as ViewGroup.MarginLayoutParams
    params.bottomMargin = insets.systemWindowInsetBottom
    binding.bottomNavigationView.layoutParams = params
    insets.consumeSystemWindowInsets()
    }

    And If you are using it in a fragment then,

    remove these following lines form the onCreate() method of the host activity,

    ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
    val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
    v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
    insets
    }

    And Add this following lines to the onViewCreated() method of the fragment

    ViewCompat.setOnApplyWindowInsetsListener(view) { v, insets ->
    val params = binding.bottomNavigationView.layoutParams as ViewGroup.MarginLayoutParams
    params.bottomMargin = insets.systemWindowInsetBottom
    binding.bottomNavigationView.layoutParams = params
    insets.consumeSystemWindowInsets()
    }

    this will solve the extra space issue.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search