Search code examples
androidandroid-layoutmaterial-designbottomnavigationview

how to set bottom navigation bar position fixed in android


please help me to set bottom navigation bar position to fixed at bottom, because I'm facing problem while entering inputs in editText fields,bottom navigation bar is moving up and overlaying on other fields

code:

<RelativeLayout 
 xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<!---     -->
 <android.support.design.widget.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:background="#FF6936C3"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_gravity="start"
        app:itemIconTint="@android:color/white"
        app:itemTextColor="@android:color/white"
        app:menu="@menu/bottom_nav_items" /> 
</RelativeLayout>

Solution

  • <LinearLayout>
      <android.support.design.widget.BottomNavigationView
       android:id="@+id/navigation"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_gravity="bottom"
       android:background="?android:attr/windowBackground"
       app:menu="@menu/navigation" />
    </LinearLayout>
    

    You can define a linear layout and put your bottom navigation in it with its gravity set to bottom. You can find the other details on: https://developer.android.com/reference/android/support/design/widget/BottomNavigationView.html