在 Kotlin 中单击外部时如何关闭底部工作表片段?

vid*_*far 5 android kotlin bottom-sheet android-bottomsheetdialog

我像这样制作底部片断:

val bottomSheet = PictureBottomSheetFragment(fragment)
bottomSheet.isCancelable = true
bottomSheet.setListener(pictureListener)
bottomSheet.show(ac.supportFragmentManager, "PictureBottomSheetFragment")
Run Code Online (Sandbox Code Playgroud)

但是当我触摸外面时它不会被解雇。并解雇或isCancelable不起作用。

小智 0

尝试这个

behavior.setState(BottomSheetBehavior.STATE_HIDDEN));
Run Code Online (Sandbox Code Playgroud)