BottomSheetDialogFragment 默认的显示方式,是有一小段是要自己滑上来的,那么如何让他显示完全呢。。。直接上代码吧,原理啥的大家也估计不爱看。。。网上大多数的代码都是有问题的,跑不了的。。。直接在onstart里面加上下面的代码就OK了
override fun onStart() {
super.onStart()
val dialog = dialog as BottomSheetDialog
if (dialog != null) {
val bottomSheet = dialog.delegate.findViewById<View>(com.google.android.material.R.id.design_bottom_sheet)
bottomSheet!!.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT //自定义高度
}
val view = view
view!!.post {
val parent = view.parent as View
val params = parent.layoutParams as CoordinatorLayout.LayoutParams
val behavior = params.behavior
val bottomSheetBehavior = behavior as BottomSheetBehavior<*>?
bottomSheetBehavior!!.peekHeight = view.measuredHeight
}
}