Open mlucchini opened 9 years ago
Ya the previous comment is right Here is the solution i have got
/**
* Call this function to resize the emoji popup according to your soft keyboard size
*/
public void setSizeForSoftKeyboard(){
rootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect r = new Rect();
rootView.getWindowVisibleDisplayFrame(r);
int screenHeight = rootView.getRootView()
.getHeight();
int heightDifference = screenHeight
- (r.bottom - r.top);
int resourceId = mContext.getResources()
.getIdentifier("status_bar_height",
"dimen", "android");
int navigation = mContext.getResources()
.getIdentifier("navigation_bar_height",
"dimen", "android");
if (resourceId > 0) {
if(Build.VERSION.SDK_INT> Build.VERSION_CODES.KITKAT)
{
heightDifference -= mContext.getResources()
.getDimensionPixelSize(resourceId);
heightDifference -=mContext.getResources().getDimension(navigation);
}else
heightDifference -= mContext.getResources()
.getDimensionPixelSize(resourceId);
}
if (heightDifference > 100) {
keyBoardHeight = heightDifference;
setSize(LayoutParams.MATCH_PARENT, keyBoardHeight);
if(isOpened == false){
if(onSoftKeyboardOpenCloseListener!=null)
onSoftKeyboardOpenCloseListener.onKeyboardOpen(keyBoardHeight);
}
isOpened = true;
if(pendingOpen){
showAtBottom();
pendingOpen = false;
}
}
else{
isOpened = false;
if(onSoftKeyboardOpenCloseListener!=null)
onSoftKeyboardOpenCloseListener.onKeyboardClose();
}
}
});
}
I found that the above code makes the popup always shorter than the keyboard. I tried several devices in the emulator, and both Lollipop and L. How can I reproduce this with an emulator?
Hi, I'm having the same problem now, shailesh242121's code is better than the original, but on some devices it doesn't quite cover the whole keyboard, did anyone figure out a solution ?
Thanks in advance.
It seems that for Lollipop, in EmojiconsPopup::setSizeForSoftKeyboard, we have to substract the size of "navigation_bar_height" as well as "status_bar_height" in case there's a navigation bar being displayed otherwise the emoji popup will take more space than the soft keyboard.