Android BottomSheetDialog content gets pushed off screen

Viewed 329

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

0 Answers
Related