Android 如何在BottomSheetDialog中更改透明背景?

Android 如何在BottomSheetDialog中更改透明背景?,android,Android,我与Dialog一起工作,遇到了一些困难。我想删除黑色背景的背景,并将其更改为透明度。我试过了,但没有成功。帮帮我 [在此处输入图像描述][1] 代码是: BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(getActivity()); View parentView = getLayoutInflater().inflate(R.layout.content_status_dialog,null); bott

我与Dialog一起工作,遇到了一些困难。我想删除黑色背景的背景,并将其更改为透明度。我试过了,但没有成功。帮帮我

[在此处输入图像描述][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();
如果我加上这样的风格

 ((View) getView().getParent()).setBackgroundColor(Color.TRANSPARENT);

,看起来是这样的

唯一需要做的是添加以下行:

if(bottomSheetDialog.getWindow() != null)
bottomSheetDialog.getWindow().setDimAmount(0);
以前

bottomSheetDialog.show();

你们试过附件问题的所有解决方案了吗?使用动画从下到上与警报框(透明)?可能重复的是,我尝试了一切。但是他们改变了对话的背景,我需要将diolog上的背景更改为透明。@Mukhit只需添加这个bottomSheetDialog.getWindow().setDimAmount(0);在bottomSheetDialog.show()之前;