BottomSheetDialogFragment 正确获取Bo

2019-02-20  本文已影响0人  tommyRen

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

上一篇 下一篇

猜你喜欢

热点阅读