Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bottom Sheet is dismissed when keyboard is open with adjustResize #153

Open
MrLepage opened this issue Aug 6, 2016 · 5 comments
Open

Bottom Sheet is dismissed when keyboard is open with adjustResize #153

MrLepage opened this issue Aug 6, 2016 · 5 comments

Comments

@MrLepage
Copy link

MrLepage commented Aug 6, 2016

I have an EditText in a bottom sheet and want to write text in it with the keyboard using windowSoftInputMode set to adjustResize.

When the EditText gain focus, keyboard open but the bottom sheet is dismissed.

With windowSoftInputMode set to adjustPan, the bottom sheet stay visible.

@Polyterative
Copy link

Same here, any idea how to solve this?

@ZacSweers
Copy link
Contributor

Sample code would help a lot

@NarendraDodiya
Copy link

I have the same issue, It can be easily reproduced.
Set windowSoftInputMode to adjustResize.

  1. Use edittext inside layout.
  2. Tap on the edittext to edit it.
  3. Now close the keyboard by pressing back button.
  4. Now tap on the edittext again. The sheet gets closed.

@NicholasJCameron
Copy link

Any solution to this.

@arnaudlvq
Copy link

arnaudlvq commented Jan 28, 2020

Ok it's very simple,

when Keyboard Shows, due to bottomSheetBehavior, the bottom sheet itself becomes invisible.

so in your hideKeyboard() methods (that you call whenever you want : ex in edittext focusChange), just put these lines at the end, so the bottom Sheet shines again !

public void hideKeyboard() {
        View view = getView();
        if (view == null) {
            view = new View(***Your activity context***);
        }
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
        yourEdittext.clearFocus();
        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
        bottomSheet.setVisibility(View.VISIBLE);
    }

enjoy :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants