4

I have a BottomSheetDialogFragment in which the user can buy stuff. To pay with a master/visa card the user is sent to the browser for a safe payment transaction.

When I return to the app again, everything is fine. But if I then close the bottom sheet dialog and open it again, the content is suddenly pushed below the screen, as shown in the Layout Inspector image below. So the user doesn't see the content anymore, he just sees the standard dark shadow which is always shown behind dialogs.

And everything works fine if I close/open the dialog for all steps except for when I close/open it after the roundtrip to the browser.

The bottom sheet is suddenly getting a way to large height (goes from ~500px in the normal case to ~1500px in the buggy case). But I don't know why.

From my investigation I'm certain that the activity is changed somehow. Either a theme flag, or similarly, changes and messes up the bottom sheet the next time.

Any thoughts on this is greatly appreciated.

Here's a somewhat simplified version of the bottom sheet xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/bottomSheetRoot"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    app:behavior_hideable="true"
    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/handle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent" />

    <com.telia.commonUI.views.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@id/handle"/>

    <androidx.core.widget.NestedScrollView
        android:id="@+id/nestedScroll"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@id/toolbar"
        app:layout_constraintBottom_toBottomOf="parent">

        <androidx.fragment.app.FragmentContainerView
            android:id="@+id/fragmentContainer"
            android:name="androidx.navigation.fragment.NavHostFragment"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

layout inspection of content pushed of screen

Algar
  • 5,734
  • 3
  • 34
  • 51
  • Does this answer your question? [BottomSheetDialog remains hidden after dismiss by dragging down](https://stackoverflow.com/questions/38804646/bottomsheetdialog-remains-hidden-after-dismiss-by-dragging-down) – digiwizkid Aug 18 '21 at 12:55
  • @digiwizkid Thank you very much for the pointer! But unfortunately there's nothing in that thread that helped. – Algar Aug 18 '21 at 13:28
  • Can you please add your java/kotlin and xml code for reference? – Android Geek Aug 23 '21 at 04:45
  • Can you add minimum reproducible example, just a skeleton project that allow anyone to give it a try. – Zain Aug 25 '21 at 00:07
  • @Zain not really, sorry. The bottom sheet has internal navigation and is a little complex. And company private I guess. – Algar Aug 26 '21 at 09:28
  • What if you designate the `wrap_content` to certain dp value .. Can this solve it? – Zain Aug 27 '21 at 02:21
  • @Zain No....... – Algar Aug 27 '21 at 09:47
  • `if I close/open the dialog...` Can you show how you open/close the dialog ... do you open it the same way when you round-trip to the browser? .. How you close the dialog, do you call dismiss(), touch outside or something else – Zain Aug 27 '21 at 11:19
  • I open it by navigating to it with Navigation (as a in the navigation graph). I'm closing it by either drag down to dismiss, or touch outside the content area. And I don't override any of that behaviour so it's all standard bottom sheet dialog behaviour. – Algar Aug 27 '21 at 11:28
  • @Algar Try defining static height to your `NestedScrollView` and/or `ConstraintLayout` one at a time and check which UI element is giving problem and then debug it. or add `minHeight` attribute to them – Noor Aug 29 '21 at 06:59
  • I would think that the activity is recreated after the payment transaction in the browser. To make testing easier, you could rotate your device and see if you can reproduce the issue like that. Not really a solution, but maybe helps you to figure out the core problem. – muetzenflo Aug 29 '21 at 10:26

0 Answers0