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:
If NestedScrollView has small content height then
BottomSheetDialogFragmentshould have height likewrap_content. IfNestedScrollViewhas a lot of content,BottomSheetDialogFragmentshould 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 - topMarginThen I set peek height:
bottomSheet.layoutParams.height = maxHeight BottomSheetBehavior.from(bottomSheet).peekHeight = maxHeightBut with this configuration if NestedScrollView has small content,
BottomSheetDialogFragmentis still expanded to max height screenshot. Is it possible to make resizableBottomSheetDialogFragmentwith max height?If the first item in
NestedScrollViewisImageView, when scrolling,BottomSheetDialogFragmentcorners are not rounded:
Same happens for another layout:
Can you point out what might be the reason for that? How do I fix it?