是否有可能加入动画表情符号在android系统消息 [英] Is it possible to add animated emoji in android messaging

查看:384
本文介绍了是否有可能加入动画表情符号在android系统消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发表情符号键盘为Android,但不知道如何在 currentInputConnection 添加一个动画表情符 InputMethodService

I am developing an emoji keyboard for android but don't know how to add a animated emoji in currentInputConnection of InputMethodService.

 Edittext content= findVie......
    sb = new SpannableStringBuilder();
            String dummyText = "-";
            sb.append(dummyText);

            try {
                sb.setSpan(anim = new AnimatedImageSpan(new AnimatedGifDrawable(
                        getAssets().open("54.gif"),
                        new AnimatedGifDrawable.UpdateListener() {
                            @Override
                            public void update() {
                                content.requestLayout();
                                content.invalidate();
                            }
                        })), sb.length() - dummyText.length(), sb.length(),
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            content.setText(sb);

下面的内容是 EDITTEXT 的看法,但我没有任何编辑文本视图。我只有 currentInputConnection 返回InputMethodService.getCurrentInputConnection()

here content is an editText view but I don't have any edit text view. All I have is currentInputConnection return by InputMethodService.getCurrentInputConnection().

推荐答案

如果我理解正确,你试图发送一个动画形象(某像GIF)来的EditText吧?据我知道,这是不可能的。如果你读过文档 InputConnection ,你应该知道,它不提供任何API来做到这一点。

If I understand you correctly, you're trying to send a "animated image" (sth like a gif) to EditText right? As far as I know, that may be impossible. If you have read the documentation of InputConnection, you should know that it doesn't provide any API to do this.

其实我的工作中,我们实现一个静态的表情符号输入键盘一个Android输入法项目。我们所要做的就是简单地通过InputConnection发送表情符号的EN codeD字节那么的笑脸出现在编辑框中。

Actually I'm working on an Android IME project in which we implement an static Emoji input keyboard. All we do is to simply send the encoded bytes of emoji through InputConnection then the smiling face appears in the edit box.

如果您已经使用微信,你可以注意其客户端已经实现了自定义的表情符号键盘(包括静态和动态内容)。这是因为他们知道他们在做什么。

If you have used WeChat, you may notice that its client has implemented a custom emoji keyboard(including static and dynamic content). That's because they know exactly what they're doing.

这篇关于是否有可能加入动画表情符号在android系统消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆