BottomSheetDialogFragment 正确获取BottomSheetBehavior 对象

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

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容