question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: touch event get wrong after folding soft keyborad

See original GitHub issue

Step 1: open bottom sheet and expanded it to top. There is a recyclerView which contains EditText items in bottom sheet; Step 2: click any EditText then soft keyboard shows; Step 3: fold the soft keyboard. And now bottom sheet keeps peeked state. Step 4: click top item of recyclerView, the bug is bottom sheet auto hides. Even if I touch the item at bottom position, the bottom sheet doesn’t work normally.

After reading source code, I think the problem happens here:(BottomSheetLayout.class line 669)

sheetViewOnLayoutChangeListener = new OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(View sheetView, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                int newSheetViewHeight = sheetView.getMeasuredHeight();
                if (state != State.HIDDEN && newSheetViewHeight < currentSheetViewHeight) {
                    // The sheet can no longer be in the expanded state if it has shrunk
                    if (state == State.EXPANDED) {
                        setState(State.PEEKED);
                    }
                    setSheetTranslation(newSheetViewHeight);
                }
                currentSheetViewHeight = newSheetViewHeight;
            }
        };

When soft keyboard is fold, the code “setSheetTranslation(newSheetViewHeight);” isn’t execute. This makes onTouchEvent works abnormally.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:3
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
meierjancommented, Jul 11, 2016

Same issue here. This is a serious bug if you are working with any kind of text input/soft keyboard.

What is the use-case for that made you add it?

if (state != State.HIDDEN && newSheetViewHeight < currentSheetViewHeight) {
  // The sheet can no longer be in the expanded state if it has shrunk
  if (state == State.EXPANDED) {
    setState(State.PEEKED);
  }
  setSheetTranslation(newSheetViewHeight);
}

Can you give me some input?

0reactions
Founder005commented, Dec 8, 2017

same problem, contains EditText items in bottomsheet I have an idea:

//screenHeight
private int screenHeight = 0;
//The height of the bottomsheet sliding up
private int keyHeight = 0;

screenHeight = this.getWindowManager().getDefaultDisplay().getHeight();
//if keyHeight is 1 / 3 of screenHeight ,we think it pop-ups
keyHeight = screenHeight / 3;

bottomsheet.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {

            @Override
            public void onLayoutChange(View v, int left, int top, int right,
                                       int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {

                //The height of the sliding up more than one-third of the screen,we think it pop-ups
                if (oldBottom != 0 && bottom != 0 && (oldBottom - bottom > keyHeight)) {
                    Log.d("keyboard ","showing");
                } else if (oldBottom != 0 && bottom != 0 && (bottom - oldBottom > keyHeight)) {
                    Log.d("keyboard ","dismiss");
                    //return PEEK state
                    bottomsheet.peekSheet();
                }
            }

 });

hope a better idea

Read more comments on GitHub >

github_iconTop Results From Across the Web

touchEvent while typing with soft keyboard android
I have already tried using dispatchTouchEvent(MotionEvent) on the main activity, but during the typing this event is not fired. Is there a way...
Read more >
X1-Fold-Bugs-Fix - English Community - Lenovo Forums
Hi guys, first post here. New owner of the X1 Fold, had it for about a week so far, and there are some...
Read more >
Need a way to disable on-screen-keyboard (OSK) - GitLab
It is very frustrating to see the on-screen-keyboard popping up while having a real keyboard connected, is there any way to disable the...
Read more >
Keyboard is not working on Galaxy phone or tablet - Samsung
If the on-screen keyboard isn't working or is unresponsive, you can fix it by optimizing your device, restarting it, or performing some other...
Read more >
Dell 2-in-1 Laptop Touchpad or Keyboard May Stop ...
Dell 2-in-1 laptops that have a tablet mode, may experience the touchpad or keyboard not working in the Operating System (OS) or in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found