Set state of BottomSheetDialogFragment to expanded

前端 未结 14 869
有刺的猬
有刺的猬 2020-11-30 19:11

How do you set the state of a fragment extending BottomSheetDialogFragment to expanded using BottomSheetBehavior#setState(STATE_EXPANDED) using the

14条回答
  •  旧时难觅i
    2020-11-30 19:37

    BottomSheetDialogFragment:

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        (dialog as? BottomSheetDialog)?.behavior?.state = STATE_EXPANDED
    }
    

    or when ready to show:

    private fun onContentLoaded(items: List) {
        adapter.submitList(items)
        (dialog as? BottomSheetDialog)?.behavior?.state = STATE_EXPANDED
    }
    

提交回复
热议问题