How to show botton navigation view below the recyclerview

Hello everyone my name is Taniguchi

i ve created a recyclerview and implemented a botton navigation view but the botton navigation view is covering up the last item of the recyclerview.

How can i show the botton navigation view below the recyclerview ?

my axml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/drawer_layout"
android:fitsSystemWindows="true">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways">

</android.support.v7.widget.Toolbar>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:minHeight="?attr/actionBarSize"
android:background="#E8E8E8"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways">






</android.support.v7.widget.Toolbar>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/btnaddnewmech"
android:layout_alignParentTop="true"
android:layout_marginTop="48sp">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViwer"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="56sp"/>
</android.support.v4.widget.SwipeRefreshLayout>

<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="start"
android:layout_alignParentBottom="true"
android:background="@android:color/white"
app:elevation="16dp"
app:menu="@menu/bottom_bar_menu">;
</android.support.design.widget.BottomNavigationView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/floating_time"
android:layout_gravity="bottom|right"
android:layout_marginRight="15dp"
android:layout_marginBottom="15dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_above="@id/fab"/>;

<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_height="match_parent"
android:layout_width="200dp"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/navigation_view"
app:headerLayout="@layout/header"/>;
</android.support.v4.widget.DrawerLayout>

Tagged:

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai

    Bottom navigation works by replacing fragments when one of the items is selected, instead of add the content directly to the layout. You should have a FrameLayout to swap in and out the fragments that will be displayed like below.

     <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/activity_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <FrameLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent" 
            android:layout_above="@+id/bottom_navigation"/>
        <android.support.design.widget.BottomNavigationView
          android:id="@+id/bottom_navigation"
          android:layout_width="match_parent"
          android:layout_height="56dp"
          android:layout_gravity="start"
          android:layout_alignParentBottom="true"
          android:background="@android:color/white"
          app:elevation="16dp"
          app:menu="@menu/bottom_navigation_main" />
          <!-- Note: background color is required to get elevation -->
      </RelativeLayout>
    

    Then handle click event. Use fragments to load the Android xml file that displays the current index it’s on.

    Check the Tutorial:
    https://devblogs.microsoft.com/xamarin/exploring-androids-bottom-navigation-view/

Sign In or Register to comment.