Android,模态底部板材对话框,高度
我想用“关闭”按钮创建模式底部板材对话框,并给他自定义高度,我尝试使用Android,模态底部板材对话框,高度,android,kotlin,height,Android,Kotlin,Height,我想用“关闭”按钮创建模式底部板材对话框,并给他自定义高度,我尝试使用discouse(),但它不起作用 给出此错误: 原因:java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法“void android.widget.ImageButton.setOnClickListener(android.view.view$OnClickListener)” 在com.example.weget.ui.home.HomeFragment.onViewCreated
discouse()
,但它不起作用
给出此错误:
原因:java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法“void android.widget.ImageButton.setOnClickListener(android.view.view$OnClickListener)”
在com.example.weget.ui.home.HomeFragment.onViewCreated上(HomeFragment.kt:41)
我的代码:
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.dismiss()
}
}
}
您可以在活动中设置主题,
覆盖bottomSheetStyle属性的行为\u Peek高度:
@样式/AppBottomSheetDialogTheme
@样式/应用模块样式
@尺寸/定制窥视高度
您能显示代码吗?请以文本而不是图像的形式输入代码。在询问之前,请阅读《如何提问》。。。
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>