Sunday 22 November 2020

DialogFragment dissapearing when opening keyboard for EditText

I have a DialogFragment that uses a layout which has ConstraintLayout inside ConstraintLayout and when I click on EditText, the keyboard opens up and dialog dissapears.

My xml structure:

<ConstraintLayout>
    <ConstraintLayout>
        <EditText>
    </ConstraintLayout>

    <ConstraintLayout>
        <EditText>
    </ConstraintLayout>
</ConstraintLayout>

I also tried out structure like this:

<ConstraintLayout>
        <EditText>
</ConstraintLayout>

And with the last structure the dialog does not dissapear.

In my code I need to have ConstraintLayout inside ConstraintLayout because I need to show one of them at some time and the other one at some other time in my dialog.

I have tried to fix it but I have no ideas left.

EDIT

I also found another reason for it happening.

<ConstraintLayout>
    <ConstraintLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
    >
        <EditText>
    </ConstraintLayout>
</ConstraintLayout>

When it's wrap_content then the dialog is not dissapearing but then the view's are not covering the whole screen.

If i change it to match_parent the dialog will look as intended but then it will start dissapearing.. So it has something to do with the match_parent dialog when keyboard shows up.



from DialogFragment dissapearing when opening keyboard for EditText

No comments:

Post a Comment