如何用左/右/下边距显示BottomSheetDialogFragment?

TOP*_*TOP 6 android margin bottom-sheet

BottomSheetDialogFragment以全屏宽度显示,没有底部边距。我想设置左/右和下边距。

我知道我们可以使用BottomSheetBehaviour它并将其应用于View布局中的对象。但我想用BottomSheetDialogFragment

Anu*_*dal -2

您可以拥有一个带有单个直系孩子的顶部。现在在顶部布局中使用背景透明和填充,并将您的内容仅放在布局中

<RelativeLayout 
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/parent_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/transparent"
            android:paddingLeft="20dp"
            android:paddingRight="20dp"
            android:paddingBottom="20dp">
   <FrameLayout>
      Content here
   </FrameLayout></RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

对我有用。