美文网首页
BottomSheetDialogFragment 正确获取Bo

BottomSheetDialogFragment 正确获取Bo

作者: tommyRen | 来源:发表于2019-02-20 15:10 被阅读0次

报错信息 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的高度 展开及合上的操作。

相关文章

网友评论

      本文标题:BottomSheetDialogFragment 正确获取Bo

      本文链接:https://www.haomeiwen.com/subject/nhjhyqtx.html