Prevent BottomSheetDialogFragment covering navigation bar

前端 未结 10 501
轮回少年
轮回少年 2020-12-12 23:49

I\'m using really naive code to show a bottom sheet dialog fragment:

class LogoutBottomSheetFragment : BottomSheetDialogFragment() {

    override fun onCrea         


        
10条回答
  •  萌比男神i
    2020-12-13 00:32

    There is a way to avoid changes in Java/Kotlin code, the issue can be fully resolved in XML nowadays:

    
    
    
    

    I also had an issue with my theme/style not being applied to the views inside BottomSheetDialogFragment, here's what I did to fix that in my base BottomSheetDialogFragment:

    override fun onGetLayoutInflater(savedInstanceState: Bundle?): LayoutInflater {
        val inflater = super.onGetLayoutInflater(savedInstanceState)
        val wrappedContext = ContextThemeWrapper(requireContext(), R.style.My_Theme)
        return inflater.cloneInContext(wrappedContext)
    }
    

提交回复
热议问题