小编Ank*_*oor的帖子


使用 BottomSheetDialogFragment 删除底表中的昏暗背景

我正在使用 BottomSheetDialogFragment 来显示底部工作表。如何去除暗淡的背景?

我已经制作了透明背景,但是当底部工作表弹出时,它下面的背景会变暗。

class ClearDataBottomSheet : BottomSheetDialogFragment {

private lateinit var contentView: View

constructor() {

}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
}

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
    val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog

    dialog.setCancelable(false)
    dialog.setOnShowListener { dialog ->
        val d = dialog as BottomSheetDialog
        val bottomSheet = d.findViewById<FrameLayout>(com.google.android.material.R.id.design_bottom_sheet)
        BottomSheetBehavior.from(bottomSheet!!).state = BottomSheetBehavior.STATE_EXPANDED
    }

    // Do something with your dialog like setContentView() or whatever
    return dialog
}

override fun setupDialog(dialog: Dialog, style: Int) {
    super.setupDialog(dialog, style)
    contentView = …
Run Code Online (Sandbox Code Playgroud)

android

3
推荐指数
1
解决办法
972
查看次数