android - Android BottomSheet 展开到另一个视图的底部
问题描述
我正在尝试使此底部工作表仅扩展到另一个视图的底部,但无法弄清楚。我希望locations_list_sheet
扩展至view1
.
我试过设置偏移量,bottomSheet.setExpandedOffset(48)
但没有运气。我也尝试在底部工作表布局的顶部设置边距,但这看起来也不正确。
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/view1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@android:color/transparent" />
<include
android:id="@+id/map_content"
layout="@layout/content_locations_stoneco" />
<include
android:id="@+id/locations_list_content"
layout="@layout/bottom_sheet_locations" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
解决方案
我不知道您将哪个特定布局用作底页我认为它必须在其中一个包含的布局中......
android:translationY="48dp"
为底部工作表布局添加一个属性
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/botto_sheet"
android:translationY="48dp"
android:background="@color/colorPrimary"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
android:layout_height="match_parent"/>
它所做的基本上是将视图向下推......就像边距一样,但有点不同。
注意:我不知道这是否是正确的方法,但它确实有效......总是欢迎提出建议
顺便说一句,您可以添加上边距也都可以
推荐阅读
- javascript - 在 camunda 建模器中的序列流上检查变量是否为空
- javascript - 多个输入的删除功能
- python - Scrapy - LinkExtractor 和设置 DEPTH_LIMIT 不起作用?
- mysql - MySql 存储过程是原子的吗?
- r - 为数据框自动生成 roxygen2 文档的最佳方法是什么?
- python - Fabric2 中的 Sudo
- javascript - 在 Vuejs 中显示数据
- powershell - 如何使用已经存在的文件夹复制文件和文件夹?
- android - 无法从 admob 加载奖励视频
- javascript - Javascript - 使用包含逗号的数组更新管道分隔符