android - 使 BottomNavigationView 停留在其他 View 下

标签 android android-layout bottomnavigationview

我已经实现了 BottomNavigationView (BNV)。我的 BNV 总是在其他 View 之上,如何让它保持在其他 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>

这是它显示的内容。

enter image description here

谢谢。

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

关于android - 使 BottomNavigationView 停留在其他 View 下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44777171/

相关文章:

android - BottomNavigationView 文本与图标重叠

android - 在支持库 28.0.0 中禁用 BottomNavigationView 的 ShiftNode

android - 安装失败,并显示消息 INSTALL_FAILED_CONFLICTING_PROVIDER

android - "removeEventListener"(android) 是否关闭 Firebase 实时数据库连接?

android - 观察 Android Jetpack DataStore 值变化

java - 在 Android 上使用 MySQL

android - 如何在 ScrollView 中将 LinearLayout 高度设置为匹配父级

android - 在运行时创建、存储和扩充自定义布局

Android - 将 View 设置在使用 Canvas 绘制的项目之上

android - 使用底部导航 View (如Youtube)处理堆栈