Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DialogFragment doesn't pan with SOFT_INPUT_ADJUST_PAN

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();
    }
like image 359
akhalsa Avatar asked May 02 '13 14:05

akhalsa


People also ask

How do I know if DialogFragment is showing?

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.

What is the difference between dialog & DialogFragment?

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.

How do you dismiss a DialogFragment?

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.

What is DialogFragment?

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.


1 Answers

Dialog layout attr. should be match_parent. When open keyboard open then strech your dialog layout. Such as samsung galaxy "create new folder" dialog.

like image 75
nurisezgin Avatar answered Sep 30 '22 17:09

nurisezgin