【发布时间】:2018-02-06 18:30:20
【问题描述】:
我的目标是在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>
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>
我对这两个元素不熟悉。有没有人知道任何方法来实现我正在寻找的东西?
我希望我的“底页”能够发挥作用并且可以扩展。我的最终目标是在BottomSheet 中添加RecyclerView。
【问题讨论】:
-
您希望底部工作表像底部工作表一样工作吗?从您的示例来看,如果您不想动画显示/隐藏底部表格,那么简单的
ImageView和TextView将为您完成这项工作。 -
我希望它这样做,我已经编辑了我的问题,谢谢
-
请看我的回答。我希望这会对你有所帮助。
标签: android material-design bottom-sheet bottomnavigationview