BottomSheetDialogFragment 修改peekHeight

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

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 中设置控件。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容