使BottomNavigationView保持在其他视图下

时间:2017-06-27 09:47:47

标签: 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.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>

这就是它的表现。

enter image description here

感谢。

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

3 个答案:

答案 0 :(得分:5)

试试这个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 :(得分:0)

Location   Group   Device# 
-------------------------- 
location1  group01  10 10
location2  group10   8 15
location2  groupxx   7 15
location3  groupAA  11 11

答案 2 :(得分:0)

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