BottomSheet DialogFragment getting covered by keyboard

153 Views Asked by At

I've seen similar questions but none of the answers solved my problem. I have a simple BottomSheetDialogFragment with an editText and a button, when I select the editText the keyboard covers the button.

I tested several answers from this question without any luck: Bottom Sheet Fragment comes up with keyboard

My BottomSheetDialogFragment:

public class AddUserBottomSheetFragment extends BottomSheetDialogFragment {

    public static AddUserBottomSheetFragment newInstance() {
        return new AddUserBottomSheetFragment();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.bottom_sheet_add_user, container);
    }

}

The fragment dialog layout:

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/bottomSheet"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/contacts_bottom_sheet_background"
    app:behavior_hideable="true"
    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
    app:behavior_peekHeight="500dp" >

    <EditText
        android:id="@+id/insert_user"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <Button
        android:id="@+id/add_user_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/contacts_add"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/insert_user" />

</androidx.constraintlayout.widget.ConstraintLayout>

And I'm showing it on my activity with this method with a simple linearLayout as argument:

public void showBottomSheet(View view) {
        AddUserBottomSheetFragment addDialogFragment = AddUserBottomSheetFragment.newInstance();
        addDialogFragment.show(getSupportFragmentManager(), "bottomSheetContainer");
    }
0

There are 0 best solutions below