我想用关闭按钮创建模态底部工作表对话框并给他自定义高度,我尝试使用dismiss(),但它不起作用
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
todayPromosList.adapter = homeFragmentAdapter
todayPromosList.layoutManager =
LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
toursList.adapter = homeFragmentAdapter
toursList.layoutManager =
LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
promotionList.adapter = homeFragmentAdapter
promotionList.layoutManager =
GridLayoutManager(context, 2)
val bottomSheetDialog = BottomSheetDialog(context!!)
bottomSheetDialog.setContentView(R.layout.dialog_search)
bottomSheetDialog.setCancelable(false)
home_search.setOnClickListener {
bottomSheetDialog.show()
}
search_dialog_ic_close.setOnClickListener {
bottomSheetDialog.setCancelable(true)
}
}
}
You can set a bottomSheetDialogTheme in your Activity,
overriding the bottomSheetStyle attribute's behavior_peekHeight:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="bottomSheetDialogTheme">@style/AppBottomSheetDialogTheme</item>
</style>
<style name="AppBottomSheetDialogTheme"
parent="Theme.Design.Light.BottomSheetDialog">
<item name="bottomSheetStyle">@style/AppModalStyle</item>
</style>
<style name="AppModalStyle"
parent="Widget.Design.BottomSheet.Modal">
<item name="behavior_peekHeight">@dimen/custom_peek_height</item>
</style>