Android 使BottomNavigationView保持在其他视图下

Android 使BottomNavigationView保持在其他视图下,android,android-layout,bottomnavigationview,Android,Android Layout,Bottomnavigationview,我已经实现了BottomNavigationView(BNV)。我的BNV始终处于其他视图的顶部,如何使其处于其他视图下 这是我的看法 <RelativeLayout xmlns:ads="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.suppor

我已经实现了BottomNavigationView(BNV)。我的BNV始终处于其他视图的顶部,如何使其处于其他视图下

这是我的看法

<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>

谢谢

编辑1:BNV下面的空白处用于AdView,我的问题是当我使用上述代码时,屏幕将变为蓝色,BNV将被隐藏。

试试这个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>

试试这个
[1]: https://i.stack.imgur.com/iyDlC.jpg


set-android:layout\u alignParentBottom=“true”@NancyY我在编辑1中更新了我的问题,谢谢。请尝试更改视图的顺序,即首先是您的
框架布局
,然后是您的
底部导航布局
。您还可以尝试在类中创建底部导航视图的实例,并调用
your_view.bringToFront()
使其可见:将BottomNavigationView置于视图组内,如LinearLayout work!您能解释一下原因吗?因为您希望在adview的底部和上方进行底部导航,所以我将其添加到视图中(称为LinearLayout),并使用android:layout\u alignParentBottom=“true”将该LinearLayout与父视图的底部对齐。其次,我根据底部布局设置框架布局,否则框架布局会重叠。因此添加了android:layout_over=“@+id/linear_bottombar”
    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.stack.imgur.com/iyDlC.jpg
<?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>