Android BottomSheet展开到另一个视图的底部

Android BottomSheet展开到另一个视图的底部,android,android-coordinatorlayout,android-bottomsheetdialog,Android,Android Coordinatorlayout,Android Bottomsheetdialog,我正试图使这个底部工作表只扩展到另一个视图的底部,但还没有找到它。我想将位置列表\u表扩展到视图1的底部 我试过设置偏移量,bottomSheet.setExpandedOffset(48),但没有成功。我也尝试过在底部页面的顶部设置一个边距,但是看起来也不对 <layout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools">

我正试图使这个底部工作表只扩展到另一个视图的底部,但还没有找到它。我想将
位置列表\u表
扩展到
视图1的底部

我试过设置偏移量,
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>

我相信它可以帮助你实现你想要的

现场示例:

<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoPanelHeight="68dp"
sothree:umanoShadowHeight="4dp">

<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:text="Main Content"
    android:textSize="16sp" />

<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center|top"
    android:text="The Awesome Sliding Up Panel"
    android:textSize="16sp" />


我不知道您使用的是哪种特定布局作为底页,我想它一定在其中一种包含的布局中

为底部图纸布局添加一个属性
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"/>

它所做的基本上是将视图向下推。。。就像保证金一样,但有点不同

注意:我不知道这样做是否正确,但确实如此 工作…建议总是受欢迎的


顺便说一句,你可以加上上上页边距,两者都会起作用

一张你想要的图片会更好。。。要找到快速解决方案,请尝试设置
app:behavior\u peek height=“48dp”
/使用
bottomSheetBehavior.setpeek height(48)
,如本文所述-@PraveenSP添加了照片。我希望底部的工作表扩展到布局顶部绿色条的底部。目前,它扩展到全屏,位于绿色栏上方。首选尝试本机解决方案(无外部库)。好的,它可能会帮助其他希望从底部扩展的人。我在我的一个老项目中使用过它。。。