gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 18:37:54 28 4
gpt4 key购买 nike

我的菜单没有粘在底部。我在 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>

最佳答案

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

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

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com