В настоящее время у меня есть фрагмент диалогового окна нижнего листа, который я хочу охватить весь экран, когда я поднимаю его, но он не работает.
Мой код выглядит следующим образом:
фрагмент_bottom_sheet_account_lo go. xml
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
...
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
LogoBottomSheetFragment.kt
class LogoBottomSheetFragment : BottomSheetDialogFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentBottomSheetAccountLogoBinding.inflate(inflater, container, false)
_viewModel = ViewModelProvider(this).get(LogoBottomSheetViewModel::class.java)
binding.viewModel = _viewModel
binding.lifecycleOwner = this
return binding.root
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val bottomSheetDialog =
super.onCreateDialog(savedInstanceState) as BottomSheetDialog
bottomSheetDialog.setOnShowListener {
val behavior: BottomSheetBehavior<*> =
BottomSheetBehavior.from(binding.cl)
behavior.skipCollapsed = true
behavior.state = BottomSheetBehavior.STATE_EXPANDED
}
return bottomSheetDialog
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
Нижний лист отображается в виде обычного диалогового окна и не может быть перемещен на весь экран. Может кто-нибудь помочь мне?
Спасибо.