經(jīng)驗(yàn)證,此方法修改有效。設(shè)置為固定高度
override fun onStart() {
super.onStart()
//修改默認(rèn)高度
val bottomSheet = dialog?.findViewById<View>(R.id.design_bottom_sheet)
val behavior = BottomSheetBehavior.from(bottomSheet)
val totalHeight = ConvertUtils.dp2px(600f)
behavior.peekHeight = totalHeight
}
也在 setUpDialog 中、onViewCreate中寫,bottomSheet 獲取不到。
實(shí)際的bottomSheet是一個(gè) FrameLayout
bottomSheet=android.widget.FrameLayout{7c5797b V.E...... ......I. 0,0-0,0 #7f090204 app:id/design_bottom_sheet}
實(shí)際使用,fragment中是在onCreateView 返回view,然后在onViewCreated 中設(shè)置控件。