将表情符号添加到Android键盘 [英] Add emoji to Android keyboard

查看:275
本文介绍了将表情符号添加到Android键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作自己的自定义键盘,但在向其中添加表情符号时遇到问题.作为android:keyIcon,我具有该表情符号的可绘制对象,因此需要android:codes.我不知道按下表情符号后会输出什么.我已经在网上寻找解决方案,但没有找到任何东西.有谁知道我应该使用什么代码来输出表情符号.预先感谢.

I'm making my own custom keyboard and I have a problem with adding emoji to it. As a android:keyIcon I have a drawable of that emoji and I need android:codes for it. I don't know what to output when emoji is pressed. I've looked online for a solution, but I haven't found anything. Does anyone know what code should I use to output an emoji. Thanks in advance.

以下是xml代码的一部分:

 <Row>
    <Key android:codes="1F926" android:keyIcon="@drawable/e415" />
    <Key android:codes="U+1F601" android:keyIcon="@drawable/e415" />
    <Key android:codes="57430" android:keyIcon="@drawable/e0415" />
</Row>

当我单击第一或第二个时,输出为空,而当我单击第二个时,输出为一些中文字母.

When I click on first or second the output is empty and when I click on the second the output is some Chinese letter.

推荐答案

您完全不需要添加任何表情符号库或更改gradle文件.示例(XML):

You should not need to add any emoji libraries or change gradle file at all. Example (XML):

<Key android:keyLabel="\u2665" android:keyOutputText="\u2665"/>

使用表情符号unicode,不带+,在代码前添加\以使用转义序列. (以上示例中使用的表情符号锹).

Use emoji unicode, without +, add \ before the code to use escape sequence. (emoji spade used in above example).

在图形中使用keyIcon,而不是keyLabel:)

use keyIcon with your graphic instead of keyLabel if needed :)

这篇关于将表情符号添加到Android键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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