BottomSheetDialogFragment 修改peek

2021-03-17  本文已影响0人  王家匀匀

经验证,此方法修改有效。设置为固定高度

override fun onStart() {
      super.onStart()

      //修改默认高度
      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 获取不到。

实际的bottomSheet是一个 FrameLayout

bottomSheet=android.widget.FrameLayout{7c5797b V.E...... ......I. 0,0-0,0 #7f090204 app:id/design_bottom_sheet}

实际使用,fragment中是在onCreateView 返回view,然后在onViewCreated 中设置控件。

上一篇 下一篇

猜你喜欢

热点阅读