Reputation: 21773
I have a DialogFragment
with two EditText
fields and another field with an ImageView
to increment its value underneath these, they all live in a ScrollView
.
The problem is neither adjust mode for the soft keyboard shows my entire DialogFragment
at once, despite there being space.
adjustResize
causes the ScrollView
to resize and hide the bottom row. adjustpan
keeps the ScrollView
size intact but the soft keyboard overlaps the bottom row.
Removing the ScrollView
means either option causes the keyboard to overlap.
What I would like is for the DialogFragment to move up the screen without resizing. Can I make that happen? Ideally I'd like to keep the ScrollView
in my Layout
to better support very small screens.
Upvotes: 2
Views: 468
Reputation: 21773
The only solution I found was to change the window options for the dialog fragment itself. Obviously on a smaller screen this will still be an issue so I am still looking for a better answer.
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
//I was using android.R.style.Theme_Translucent_NoTitleBar for another issue
//but I don't think the theme makes any difference to how the window is laid out
//that is relevant to the below code
Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Translucent_NoTitleBar);
... //Do your usual stuff here
dialog.getWindow().setContentView(...);
final WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
params.gravity = Gravity.TOP; //this is the important part
dialog.setCanceledOnTouchOutside(false);
return dialog;
}
Upvotes: 1