0

I have a BottomSheetDialogFragment with rounded corners (There was a problem that corners weren't rounded in BottomSheetBehavior.STATE_EXPANDED, but I fixed it with Round corner for BottomSheetDialogFragment). Inside BottomSheetDialogFragment I have NestedScrollView.

There are two problems:

  1. If NestedScrollView has small content height then BottomSheetDialogFragment should have height like wrap_content. If NestedScrollView has a lot of content, BottomSheetDialogFragment should have max height (with some margin from top) and be scrollable.

    Currently I configure peek height for BottomSheetDialogFragment. Max height is calculated like this:

    val displayMetrics = requireActivity().resources.displayMetrics
    val height: Int = displayMetrics.heightPixels
    val maxHeight = height - topMargin
    

    Then I set peek height:

    bottomSheet.layoutParams.height = maxHeight
    BottomSheetBehavior.from(bottomSheet).peekHeight = maxHeight
    

    But with this configuration if NestedScrollView has small content, BottomSheetDialogFragment is still expanded to max height screenshot. Is it possible to make resizable BottomSheetDialogFragment with max height?

  2. If the first item in NestedScrollView is ImageView, when scrolling, BottomSheetDialogFragment corners are not rounded:

Same happens for another layout:

Can you point out what might be the reason for that? How do I fix it?

Mike Makhovyk
  • 196
  • 1
  • 9

0 Answers0