0

In my BottomSheetDialogFragment I use this option (fitsSystemWindows = false) to fix strange effect while scrolling to bottom example gif (MapView is on top of navigation bar)

 override fun onActivityCreated(savedInstanceState: Bundle?) {
    super.onActivityCreated(savedInstanceState)
    (requireView().parent.parent.parent as View).fitsSystemWindows = false
  }

But than it causes another problem, when any view's size changes or EditText receives focus dialog height were jumped on top of status bar and navigation bar is also transparent example 2 gif

Does anyone had the same problem or any idea how to fix this strange jumps

Jemo Mgebrishvili
  • 5,187
  • 7
  • 38
  • 63
  • How did you apply the rounded corners? I tried lots of things until my code behaved right, i can share my code but best way is make sample project and see if my approach works there. I'm away from laptop now can't share code. – Fabio Jul 25 '20 at 12:33
  • I'm using this setStyle(STYLE_NO_TITLE, R.style.MyDialogStyle) ( @android:color/transparent ) than I have rounded corner shape drawable in my dialog layout – Jemo Mgebrishvili Jul 25 '20 at 14:45
  • yep I think that's the reason. I tried something liike that too and didn't get the results I wanted. – Fabio Jul 26 '20 at 02:14

1 Answers1

0

This is what worked for me in one of my projects. It will make all of your bottom sheet dialog fragments to have the same shape. And its contents will scroll without moving that shape.

Note that if your AppTheme inherits from a different theme your mileage may vary. Let me know if this doesn't do anything at all on your project, I have another project that may have a small variation on how this is done.

 <!--    https://material.io/develop/android/theming/dark/ -->
 <style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">

        <item name="bottomSheetDialogTheme">@style/AppTheme.RoundedBottomSheet</item>


 </style>

<style name="AppTheme.RoundedBottomSheet" parent="Theme.Design.Light.BottomSheetDialog">
    <item name="bottomSheetStyle">@style/AppModalStyle</item>
</style>
Fabio
  • 2,654
  • 16
  • 31
  • Rounded corner is applied, but problem is same, dialog steel jumps on top of status bar when edittext receives focus – Jemo Mgebrishvili Jul 26 '20 at 08:45
  • If I remove this line (requireView().parent.parent.parent as View).fitsSystemWindows = false than it stops jumping but than MapView is on top of navigation bar – Jemo Mgebrishvili Jul 26 '20 at 08:48