Harry T.
Harry T.

Reputation: 3527

Make BottomNavigationView stay under other view

I've implemented BottomNavigationView (BNV). My BNV always stay on top of other view, how can I make it stay under other view?

This is my View

<RelativeLayout xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
<android.support.design.widget.BottomNavigationView
            android:id="@+id/bottomNavi"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/color_bottom_navi"
            app:itemBackground="@drawable/selector_navi_bottom"
            app:itemIconTint="@color/colorPrimary"
            app:itemTextColor="@color/colorPrimary"
            app:menu="@menu/bottom_navigation" />
        <FrameLayout
            android:id="@+id/frm_content_full"
            android:layout_width="match_parent"
            android:background="@color/colorPrimaryDark"
            android:layout_height="match_parent" />
    </RelativeLayout>

This is what it shown.

enter image description here

Thanks.

EDIT 1: The space below BNV is for AdView, my question is about when I use above code, screen will become Blue, BNV will be hidden.

Upvotes: 9

Views: 8036

Answers (3)

MRX
MRX

Reputation: 1442

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:fitsSystemWindows="true"
  android:orientation="vertical"
  tools:context="com.study.navcon.module.home.HomeScreenActivity">

  <RelativeLayout
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.Toolbar
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="?attr/colorPrimary"
      android:minHeight="?attr/actionBarSize"
      app:titleTextColor="@android:color/white"/>


    <FrameLayout
      android:id="@+id/fragment_container"
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_marginBottom="50dp"
      android:layout_above="@+id/navigation"
      android:animateLayoutChanges="true"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"/>


    <android.support.design.widget.BottomNavigationView
      android:id="@+id/navigation"
      android:layout_width="match_parent"
      android:layout_height="50dp"
      android:layout_alignParentBottom="true"
      android:background="?android:attr/windowBackground"
      app:menu="@menu/navigation"/>

  </RelativeLayout>
</LinearLayout>

Upvotes: 0

Rashmi Bhandari
Rashmi Bhandari

Reputation: 458

    try this

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout 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">

        <FrameLayout
            android:id="@+id/frm_content_full"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/colorPrimaryDark" />

        <android.support.design.widget.BottomNavigationView
            android:id="@+id/bottomNavi"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            app:itemBackground="@android:color/holo_red_light"
            app:itemIconTint="@android:color/white"
            app:itemTextColor="@android:color/white"
            app:menu="@menu/bottom_navigation_main" />

    </RelativeLayout>


  [1]: https://i.sstatic.net/iyDlC.jpg

Upvotes: -1

Yyy
Yyy

Reputation: 2335

Try this xml

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

    <FrameLayout
        android:id="@+id/frm_content_full"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/linear_bottombar"
        android:background="@color/colorPrimaryDark" />


    <LinearLayout
        android:id="@+id/linear_bottombar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="vertical">

        <android.support.design.widget.BottomNavigationView
            android:id="@+id/bottomNavi"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/color_bottom_navi"
            app:itemBackground="@drawable/selector_navi_bottom"
            app:itemIconTint="@color/colorPrimary"
            app:itemTextColor="@color/colorPrimary"
            app:menu="@menu/bottom_navigation" />

        <!--your adview-->

    </LinearLayout>
</RelativeLayout>

Upvotes: 14

Related Questions