android - BottomNavigationView 不显示在底部,而是显示在顶部

标签 android

我的菜单没有粘在底部。我有一个菜单,位于 BottomNavigationView 中。导航 View 包含在布局中。我尝试将重力设置为底部,设置约束,alignparentbottom,但它仍然显示在布局的顶部。下面是我的菜单、导航和布局的代码。

我添加了一张图片来说明问题:

enter image description here

我的菜单。它有一些菜单项:

<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <--- items here --->
</menu>

我的底部导航 View :

    <android.support.design.widget.BottomNavigationView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        app:menu="@menu/nav_menu"
        android:id="@+id/bottom_menu_layout"
        android:layout_gravity="bottom">

        <View
            android:layout_width="fill_parent"
            android:layout_height="2dip"
            android:background="#D3D3D3" />

    </android.support.design.widget.BottomNavigationView>

我的布局文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:include="http://schemas.android.com/apk/res-auto">


    <TextView
        android:id="@+id/mainlayouttext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="@string/maintextview"
        include:layout_constraintBottom_toBottomOf="parent"
        include:layout_constraintEnd_toEndOf="parent"
        include:layout_constraintStart_toStartOf="parent"
        include:layout_constraintTop_toTopOf="parent" />

    <include layout="@layout/meny_bottom_layout" />
</android.support.constraint.ConstraintLayout>

最佳答案

您的包含未指定任何约束。如果我在你身边,我会尝试类似的事情

    <include
            android:layout_height="0dp"
            android:layout_width="0dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"  
            layout="@layout/meny_bottom_layout"/>
如果您希望考虑其他包含的参数,

android:layout_heightandroid:layout_width 是必需的

关于android - BottomNavigationView 不显示在底部,而是显示在顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53650551/

相关文章:

android - 在全屏视频上添加全屏按钮

java - Listview的HashMap背景颜色值

java - 在 Java 中创建新的 Activity() 时抛出异常

android - Google Play 结算订阅 : new policy for mandatory "Hold": what needs to be changed in the app UI?

java - helper 处理循环

Android Studio 未运行显示 "force close"的应用程序

java - GenericPool 可重用每秒所需的 Sprite

android - 无法正确获取 "android.intent.action.SEND" Intent 的路径

android 在 ViewPager 中更改 textView

java - 从 android 中的 Activity 发送字符串数组