底部导航上方的底部工作表

2024-01-17

我的目标是将“底页”放在BottomNavigationView像这样:

但它仍然保持以下方式。两种观点都崩溃了:

这是我的主要活动的 xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 
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:background="@drawable/tierrota"
tools:context="com.example.juanjose.myapplication.ViajesActivity">

<!-- include main content -->
<include layout="@layout/bottomsheet" />

<!-- include bottom sheet -->
<include layout="@layout/bottom_navigation" />

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

Code of bottom_navigation:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<android.support.design.widget.BottomNavigationView
    android:id="@+id/bottom_navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    app:itemBackground="@color/colorClarito"
    app:itemIconTint="@drawable/nav_item_color_state"
    app:itemTextColor="@drawable/nav_item_color_state"
    app:menu="@menu/bottom_navigation_main" />

</RelativeLayout>

以及底页的代码

<?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"
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:behavior_hideable="false"
app:behavior_peekHeight="80dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

<TextView
    android:layout_width="match_parent"
    android:layout_height="80dp"
    android:background="@color/colorBackgroundSemi"
    android:gravity="center"
    android:text="Bandeja de entrada"
    android:fontFamily="@font/eraslght"
    android:textColor="@color/colorLetra"
    app:layout_anchor="@+id/bottom_navigation"
    app:layout_anchorGravity="top"/>

<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:text="coisa2"
    android:textColor="@android:color/white" />

</LinearLayout>

我对这两个元素很陌生。有人知道有什么方法可以实现我正在寻找的东西吗?

我希望我的“底页”能够起到这样的作用并且可以扩展。我的最终目标是添加一个RecyclerView在 - 的里面BottomSheet.


要使用底页,它应该是协调器布局。这里我使用相对布局作为底部导航的父布局,使其位于底部,然后将 CoordinatorLayout 置于底部导航之上。 这是一个article https://iamnaran.medium.com/bottom-sheet-above-bottom-navigation-b10a0c92edd这会对你有所帮助。

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_above="@id/bottom_navigation_parent"
        android:layout_height="match_parent">


        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">


            <FrameLayout
                android:id="@+id/container"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="?attr/colorPrimary" />


        </RelativeLayout>


        <RelativeLayout
            android:id="@+id/bottom_sheet_parent"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#000000"
            app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

            <LinearLayout
                android:id="@+id/bottom_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <View
                    android:layout_width="20dp"
                    android:layout_height="4dp"
                    android:layout_gravity="center"
                    android:layout_marginTop="10dp"
                    android:background="@drawable/view_bottom_sheet_top" />

                <TextView
                    android:id="@+id/near_by"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:fontFamily="@font/normal"
                    android:gravity="center"
                    android:includeFontPadding="false"
                    android:padding="10dp"
                    android:text="Book Now"
                    android:textAllCaps="true"
                    android:textColor="?attr/colorPrimaryText"
                    android:textSize="12sp" />

            </LinearLayout>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recycler_view_maps"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/bottom_view"
                android:layoutAnimation="@anim/layout_animation">

            </android.support.v7.widget.RecyclerView>

        </RelativeLayout>



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

    <android.support.design.widget.AppBarLayout
        android:id="@+id/bottom_navigation_parent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:fitsSystemWindows="true"
        app:elevation="1dp">

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/colorContainerBackground"

            />
<!--              Start BottomNavigationView -->

       
<!--              End BottomNavigationView -->


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


</RelativeLayout>

不要忘记将其添加到您的 Activity/Fragment 中

private RelativeLayout bottomSheetParentLayout;
    private BottomSheetBehavior mBottomSheetBehaviour;

   mBottomSheetBehaviour = BottomSheetBehavior.from(bottomSheetParentLayout);

  if (bottomNavigation != null) {

        mBottomSheetBehaviour.setPeekHeight(bottomNavigation.getHeight() + 90);

    }
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

底部导航上方的底部工作表 的相关文章

随机推荐

  • 如何在 dart 代码中执行 flutter 终端命令

    我想自动化我的项目的测试 我需要截取屏幕截图并与其他屏幕截图进行比较 Flutter 命令将截取屏幕截图并将其保存到我的目录中 所以我想在 dart 而不是终端中执行该命令 我在截取屏幕截图时遇到问题 已经使用了一些软件包 例如屏幕截图等
  • Angular:如何重置子组件

    我编写了一个 Java 后端 用作我的服务器并将提供所有数据 前端是 Angular 8 应用程序 我在 stackblitz 中创建了前端应用程序的精简版本 https stackblitz com edit angular code g
  • docker 在后台运行 shell 脚本而不退出容器

    我正在尝试在我的 docker 容器中运行 shell 脚本 问题是 shell 脚本生成另一个进程 并且它应该继续运行 除非使用另一个关闭脚本来终止启动脚本生成的进程 当我运行以下命令时 docker run image tag bin
  • 使用 Bluebird Promise 的 While 循环

    我正在尝试使用 Promise 来实现 while 循环 这里概述的方法似乎有效 http blog victorquinn com javascript promise while loop http blog victorquinn c
  • 如何在 IronPython 中卸载 .NET 程序集引用

    加载对程序集的引用后 如下所示 import clr clr AddRferenceToFileAndPath r C foo dll 如何再次卸载组件 为什么有人想要这样做 因为我正在重新编译foo dll并想重新加载它 但编译器让我大惊
  • Pandas:如何从周和年创建日期时间对象?

    我有一个数据框 它提供了两个整数列 其中包含一年中的年份和星期 import pandas as pd import numpy as np L1 43 44 51 2 5 12 L2 2016 2016 2016 2017 2017 20
  • jQuery 的 .delay 方法在幕后是如何工作的?

    我刚看到这个 觉得很酷 console log Starting my element fadeIn delay 3000 fadeOut console log Finishing delay 方法在幕后是如何工作的 我的意思是 它是如何
  • 记录用户交互:log4j?

    我需要你的建议 我有一个Java应用程序 我想记录用户使用我的应用程序的方式 我想知道最常用的按钮是什么 计算应用程序中介绍新患者的平均时间 ETC 您认为最好 最简单的方法是什么 是使用Log4j吗 谢谢您的合作 此致 Daniel 考虑
  • 在新窗口中打开的Web资源中使用Xrm.WebApi方法

    我使用以下命令在新窗口中打开了 HTML Web 资源 Xrm Navigation openWebResource webResource windowOptions data 这是一个 HTML Web 资源 它正在头部加载 Clien
  • 无法在 Flink 新 Kafka Consumer-api (1.14) 中的检查点上向 Kafka 提交消费偏移量

    我使用以下代码引用 Kafka 源连接器的 Flink 1 14 版本 我期待以下要求 在应用程序刚开始时必须读取 Kafka 主题的最新偏移量 在检查点上 它必须将消耗的偏移量提交给 Kafka 重新启动后 当应用程序手动终止 系统错误时
  • PHP 中 /Filter /FlateDecode PDF 流中的数据提取

    我无法解密流中的数据 例如 56 0 obj lt lt Length 1242 Filter FlateDecode gt gt stream x n b Kq whole binary is omitted endstream endo
  • Leaflet MarkerCluster:是否可以打开多个集群组?

    我最近开始使用传单 我发现了很棒的插件传单标记集群 我目前正在尝试同时打开多个集群组 不幸的是我在谷歌上找不到任何东西 我有几个聚类组 并从一个标记到另一个标记建立连接 用户应该能够打开所绘制的线所属的两个集群组 因此我的问题是 是否有一个
  • SciPy KDE 梯度

    我正在使用内核密度估计 KDE 的 SciPy 实现 http docs scipy org doc scipy reference generated scipy stats gaussian kde html http docs sci
  • java web 服务的推荐框架[关闭]

    就目前情况而言 这个问题不太适合我们的问答形式 我们希望答案得到事实 参考资料或专业知识的支持 但这个问题可能会引发辩论 争论 民意调查或扩展讨论 如果您觉得这个问题可以改进并可能重新开放 访问帮助中心 help reopen questi
  • 从一个文件绘制多个数据集

    注意 我可以控制数据文件的格式 但它必须是单个文件 我正在尝试使用 gnuplot 在同一个图表上绘制多个数据集 理想情况下我想绘制这样的东西 data 1 0 0 data 2 0 0 data 1 1 1 data 2 0 1 data
  • 解析json数组?

    我有一个如下所示的 JSON agentsArray ID 570 picture 03803 png name Bob ID 571 picture 02103 png name Tina 现在我试图循环每个数组元素 使用qt json图
  • 如何在 C# 中同时将控制台输出到多个流?

    我有一个程序 它获取控制台输出并将其写入日志文件 但它不再显示在控制台窗口中 有没有办法将其保留在窗口中 但也将其写入日志文件 Update appLogStream new FileStream logFile FileMode Appe
  • MacOSbrew安装libsndfile但仍然找不到

    我刚刚从 Windows 切换到 Mac 并且尝试使用 brew 为我的一个 C 项目安装 libsndfile 但安装后仍然显示终端中找不到错误 我似乎无法弄清楚为什么 brew install libsndfilelibsndfile
  • Azure - 在 Java Spring Boot 中使用用户管理身份访问 Key Vault:错误详细信息:ManagedIdentityCredential 身份验证不可用?

    我有一个 Java Spring boot 应用程序 仅从 Azure Key Vault 读取机密 以下是使用的步骤 创建了应用程序注册 复制应用程序注册详细信息 生成的秘密 授予对 Azure Key Vault 的访问权限 下面是我的
  • 底部导航上方的底部工作表

    我的目标是将 底页 放在BottomNavigationView像这样 但它仍然保持以下方式 两种观点都崩溃了 这是我的主要活动的 xml