How to set maximum expanded height in android support design bottom sheet?

前端 未结 4 1684
臣服心动
臣服心动 2020-12-24 06:46

I already showed my bottom sheet layout with its peek height set to 100dp. But how can I limit my bottom sheet to expand to 500dp only? This is my sample layout:

<         


        
4条回答
  •  天涯浪人
    2020-12-24 07:04

    Above solutions didn't work for me so I solved it by

    1. added app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" in the root view of bottom sheet layout.

    2. custom style for bottom sheet:

    
    
        

    3. And using this in Activity or Fragment by

        val mBottomSheetDialog = BottomSheetDialog(this, R.style.AppBottomSheetDialogTheme)
        val inflater = this.layoutInflater
        val sheetView = inflater.inflate(R.layout.bottom_sheet_layout, null)
        mBottomSheetDialog.setContentView(sheetView)
        mBottomSheetDialog.show()
    

提交回复
热议问题