Premise: with "on top of" I mean "overlaying", with a "higher z-index", so to speak; with "above" I mean "visually above, on the screen".
I guess the question would be "how to display a PopupWindow on top of the keyboard when a Dialog is showing?". Following, the situation...
I'm using this library to have Whatsapp-style emojicons in my app. The way it shows the emojicons in place of the soft-keyboard is by displaying a PopupWindow
on top of it, so that it covers it completely.
To create the emojicon's popup, I need to pass a View
to the constructor. I tried passing two different views and it doesn't work with either of them. Here's what happens:
If I pass the dialog's root view (with
getRootView()
), the popupwindow doesn't appear on top of the keyboard, but on top of the dialog. After debugging I understood that it's because the dialog's root view doesn't take the whole screen but exactly the dialog's size. I thought it would be larger because of the fact that the dimmed background behind the dialog occupies all the screen. I was wrong.
The popup is interact-able and working as it should.If I pass the root view of the activity that contains the dialog, the popup not only appears behind the dialog and the dimmed background (thus being impossible to interact with), but also appears above the keyboard! here's a screenshot:
Why does it appear there instead of on top of the keyboard? I really don't understand.
I already tried by changing the windowSoftInputMode
and setting the PopupWindow
's "InputMethodMode" to PopupWindow.INPUT_METHOD_NOT_NEEDED
, but the results are always the same.
To create and show the popup, the library simply calls
public class EmojiconsPopup extends PopupWindow ... {
...
setSize(LayoutParams.MATCH_PARENT, keyBoardHeight);
...
showAtLocation(rootView, Gravity.BOTTOM, 0, 0);
...
}
when the keyboard is open.
You can see the library's source code from the link I wrote at the beginning, and here's an open issue about this problem, in case it may contain additional useful info.
Thanks for the help.