使用支持库中的BottomSheet时如何调暗背景?

背景如何能像这里显示的那样变暗?

我通常使用CoordinatorLayoutBottomSheetBehavior来设置它。


这将只显示底部表单。

public class MyBottomSheet extends BottomSheetDialogFragment {
    private static final String TAG = "MyBottomSheet";

    @NonNull
    @Override
    public Dialog onCreateDialog(final Bundle savedInstanceState) {
        final BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);

        final View view = View.inflate(getContext(), R.layout.my_custom_view, null);

        dialog.setContentView(view);
        behavior = BottomSheetBehavior.from((View) view.getParent());

        return dialog;
    }

    public void show(final FragmentActivity fragmentActivity) {
        show(fragmentActivity.getSupportFragmentManager(), TAG);
    }
}

简单地按照正常的方式调用close()来关闭对话框。


使用BottomSheetDialog

基本上它是一个对话框(即支持暗淡)和支持模式底部表单行为尝试

链接地址: http://www.djcxy.com/p/92355.html

上一篇: How to dim background when using the BottomSheet from the support library?

下一篇: Combining several static libraries into one using CMake