报错信息 The view is not a child of CoordinatorLayout
在BottomSheetDialogFragment里正确获取 BottomSheetBehavior 对象 下边是代码
lateinit val bottomSheetBehavior : BottomSheetBehavior
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
dialog.setOnShowListener{ dialog->
val d = dialogas BottomSheetDialog
val bottomSheetInternal = d.findViewById(android.support.design.R.id.design_bottom_sheet)
bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetInternal)
}
return super.onCreateView(inflater, container, savedInstanceState)
}
获取到想要的对象 然后我们可以改变UI的高度 展开及合上的操作。
网友评论