I have a dialogfragment which has some content in it including an EditText field.
Unfortunately when I click on the EditText field, the softkeyboard covers the dismiss button for the dialog. This is a problem which I resolved by using
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Unfortunately, when I do this, the dialog shrinks and other items in it get covered. I tried using SOFT_INPUT_ADJUST_PAN
instead, but only the containing activity adjusted in that case, the dialogfragment itself didn't move and the dismiss buttons are still covered. Is there any way I can make just the dialogfragment pan?
My relevant dialogfragment code looks like this:
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
mContactSupportView.findViewById(R.id.compose_message).clearFocus();
}
Showing the DialogFragment Instead, use the show() method to display your dialog. You can pass a reference to a FragmentManager and a String to use as a FragmentTransaction tag.
Dialog: A dialog is a small window that prompts the user to make a decision or enter additional information. DialogFragment: A DialogFragment is a special fragment subclass that is designed for creating and hosting dialogs.
tl;dr: The correct way to close a DialogFragment is to use dismiss() directly on the DialogFragment. Control of the dialog (deciding when to show, hide, dismiss it) should be done through the API here, not with direct calls on the dialog. Dismiss the fragment and its dialog.
Android DialogFragments. DialogFragment is a utility class which extends the Fragment class. It is a part of the v4 support library and is used to display an overlay modal window within an activity that floats on top of the rest of the content. Essentially a DialogFragment displays a Dialog but inside a Fragment.
Dialog layout attr. should be match_parent. When open keyboard open then strech your dialog layout. Such as samsung galaxy "create new folder" dialog.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With