底部导航上方的底部工作表 [英] Bottom Sheet Above Bottom Navigation
问题描述
我的目标是在 BottomNavigationView
上方放置一个底页,如下所示:
My goal is to place a "bottom sheet" on top of a BottomNavigationView
like this:
< a href = https://i.stack.imgur.com/FVQ7D.jpg rel = nofollow noreferrer>
但是它保持以下方式。两种视图都折叠:
But it stays the following way. Both views collapse:
这是xml我的主要活动:
This is the xml of my main activity:
<?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>
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>
我对这两个要素不熟悉。
I am new with these two elements. Is there someone who knows any way to achieve what I'm looking for?
我希望我的基本工作表照此行事并可以扩展。我的最终目标是在 BottomSheet
内添加 RecyclerView
。
I want my "bottom sheet" to act as such and can expand. My ultimate goal is to add a RecyclerView
inside the BottomSheet
.
推荐答案
将两个元素包装在线性布局中。不确定协调器布局的行为方式,但我认为它不允许您对元素进行排序(类似于框架布局)。
Wrap the two elements inside a linear layout. Not sure how coordinator layout behaves but I think it will not allow you to "order" elements (similar to frame layout).
这篇关于底部导航上方的底部工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!