Android用Emoji Fragment替换键盘

sta*_*ete 4 keyboard android emoticons switch-statement emoji

我正在我的应用程序中进行一些聊天,我有一个表情片段(就像来自whatsapp或电报的那个).如何在没有任何奇怪动画的情况下在片段和键盘之间切换?

我已经有了emojis和自定义EditText的片段.我只想切换那个片段和键盘.我真的希望它像whatsapp或Telegram一样工作.

对于表情符号Fragment,我创建了一个库.我在与EditText相同的布局中添加一个片段(每个表情符号的带有SpannableTextViews的网格视图).

任何帮助将非常感激.

ele*_*ven 9

您不需要更换键盘,你可以使用把你的片段在活动PopupWindowTelegram一样.只需查看:方法showEmojiPopup创建EmojiView并将其放入其中PopupWindow然后计算适当的大小并显示它.

emojiPopup.setHeight(View.MeasureSpec.makeMeasureSpec(currentHeight, View.MeasureSpec.EXACTLY));
emojiPopup.setWidth(View.MeasureSpec.makeMeasureSpec(contentView.getWidth(), View.MeasureSpec.EXACTLY));

emojiPopup.showAtLocation(parentActivity.getWindow().getDecorView(), 83, 0, 0);
Run Code Online (Sandbox Code Playgroud)