如何更改BottomSheetDialog中的透明背景?

Muk*_*hit 3 android

我使用 BottomSheetDialog,出现了一些困难。我想删除黑色背景的背景,并将其更改为透明。我尝试了这个带有透明背景的 BottomSheetDialog,但没有成功。帮我。

[在此输入图像描述][1]

代码是:

BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(getActivity());
    View parentView = getLayoutInflater().inflate(R.layout.content_status_dialog,null);
    bottomSheetDialog.setContentView(parentView);
    BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from((View)parentView.getParent());
    bottomSheetDialog.setCancelable(true);
    bottomSheetBehavior.setPeekHeight((int)TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP,100,
            getResources().getDisplayMetrics()));

    bottomSheetDialog.show();
Run Code Online (Sandbox Code Playgroud)

如果我添加一些像这样的样式

 ((View) getView().getParent()).setBackgroundColor(Color.TRANSPARENT);
Run Code Online (Sandbox Code Playgroud)

,它看起来像这样

小智 6

唯一需要做的就是添加这一行:

if(bottomSheetDialog.getWindow() != null)
bottomSheetDialog.getWindow().setDimAmount(0);
Run Code Online (Sandbox Code Playgroud)

bottomSheetDialog.show();
Run Code Online (Sandbox Code Playgroud)