8

I have some dialog with EditText fields. when i want to fill some EditText the keyboard is opened and I can't fill some fields above. i should close the keyboards and after click on EditText above. How can I make my dialog scrollable when the keyboard is on to avoid closing the keyboard?

HK.avdalyan
  • 724
  • 1
  • 6
  • 21

3 Answers3

11

Try:

dialog.getWindow().setSoftInputMode(
    WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
FirstOne
  • 6,033
  • 7
  • 26
  • 45
Amol Desai
  • 872
  • 1
  • 9
  • 17
0

Add windowSoftInputMode to activity in manifest

<activity
...
    android:windowSoftInputMode="stateHidden|adjustResize">
asannov
  • 189
  • 2
  • 8
0

xml (dialog_layout.xml):

<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <androidx.cardview.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardCornerRadius="10dp"
        android:elevation="5dp">

    </androidx.cardview.widget.CardView>

</androidx.core.widget.NestedScrollView>

java:

final Dialog dialog = new Dialog(this);
            dialog.setContentView(R.layout.dialog_layout);
            dialog.setCanceledOnTouchOutside(false);
            Objects.requireNonNull(dialog.getWindow()).setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    dialog.show();
Mohsen_AB
  • 41
  • 1
  • 5