Android:如何在表情符号的软键盘上添加子视图?

Android:如何在表情符号的软键盘上添加子视图?,android,keyboard,emoji,Android,Keyboard,Emoji,我想使用EmojiView在键盘顶部添加一个带有EmojiView的视图。现在,我想要的功能就像我在EmojiView上输入的主代码一样。我想在软键盘上显示一个EmojiView。方法类似于将“从自己的视图中拾取”添加为键盘的子视图 我该怎么做 谢谢你提前通知。请分享您的代码。您可以使用弹出窗口,它显示在软键盘顶部。 查看项目中的添加库并使用以下代码: LayoutInflater layoutInflater = (LayoutInflater) getBaseContext().getSys

我想使用EmojiView在键盘顶部添加一个带有EmojiView的视图。现在,我想要的功能就像我在EmojiView上输入的主代码一样。我想在软键盘上显示一个EmojiView。方法类似于将“从自己的视图中拾取”添加为键盘的子视图

我该怎么做


谢谢你提前通知。请分享您的代码。

您可以使用弹出窗口,它显示在软键盘顶部。

查看项目中的添加库并使用以下代码:

LayoutInflater layoutInflater = (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);

View popupView = layoutInflater.inflate(R.layout.popup, null);
popupWindow = new EmojiconsPopup(popupView, getApplicationContext());
// final PopupWindow popupWindow = new PopupWindow();
popupWindow.setSizeForSoftKeyboard();
popupWindow.setSize(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
popupWindow.showAtLocation(mInputView.getRootView(), Gravity.BOTTOM, 0, 0);

// Bring soft keyboard up : NOT WORKING
final InputMethodManager mInputMethodManager = (InputMethodManager) getBaseContext()
    .getSystemService(Context.INPUT_METHOD_SERVICE);

mInputMethodManager.showSoftInput(popupView, 0);

// If the text keyboard closes, also dismiss the emoji popup
popupWindow.setOnSoftKeyboardOpenCloseListener(new OnSoftKeyboardOpenCloseListener() {

    @Override
    public void onKeyboardOpen(int keyBoardHeight) {

    }

    @Override
    public void onKeyboardClose() {
        if (popupWindow.isShowing())
        popupWindow.dismiss();
    }
});

popupWindow.setOnEmojiconClickedListener(new OnEmojiconClickedListener() {

    @Override
    public void onEmojiconClicked(Emojicon emojicon) {
        mComposing.append(emojicon.getEmoji());
        commitTyped(getCurrentInputConnection());

        customToast("" + emojicon.getEmoji());
    }
});

popupWindow.setOnEmojiconBackspaceClickedListener(new OnEmojiconBackspaceClickedListener() {

    @Override
    public void onEmojiconBackspaceClicked(View v) {
        KeyEvent event = new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL);
        customToast(" " + event);
        handleBackspace();
    }
});

但我有这个项目,但如何在IME中实现。您是否尝试从视图类使用onKeyPreIme()?有了这个你可以抓住按键