如何在android中添加自定义图像作为表情符号
我一直在搜索,但没有在android应用程序中添加自定义图片作为表情符号的结果。谢谢你的帮助 我的问题是: 我试着在android上做一个自定义键盘,它只包括像表情符号这样的自定义图像,我设法在键盘上显示图像,但当我尝试发送它时,我得到了[OBJ]作为回报 这里是我的一些代码,我尝试了很多可能的方法如何在android中添加自定义图像作为表情符号,android,html,image,keyboard,textview,Android,Html,Image,Keyboard,Textview,我一直在搜索,但没有在android应用程序中添加自定义图片作为表情符号的结果。谢谢你的帮助 我的问题是: 我试着在android上做一个自定义键盘,它只包括像表情符号这样的自定义图像,我设法在键盘上显示图像,但当我尝试发送它时,我得到了[OBJ]作为回报 这里是我的一些代码,我尝试了很多可能的方法 String s = "<img src='a.png'/>"; // Spanned cs = Html.fromHtml("<img src='" + ge
String s = "<img src='a.png'/>";
// Spanned cs = Html.fromHtml("<img src='" + getResources().getDrawable(R.drawable.a) + "'/>", imageGetter, null);
/* ic.commitText( Html.fromHtml(s, new Html.ImageGetter() {
@Override public Drawable getDrawable(String source) {
Drawable drawFromPath;
int path =
emoji.this.getResources().getIdentifier(source, "drawable",
"com.cmosteknoloji.emoji");
drawFromPath = (Drawable) emoji.this.getResources().getDrawable(path);
drawFromPath.setBounds(0, 0, drawFromPath.getIntrinsicWidth(),
drawFromPath.getIntrinsicHeight());
return drawFromPath;
}
}, null),1);*/
Spanned spanned = Html.fromHtml(s, this, null);
ic.commitText(spanned,1);
嗨,我在尝试同样的方法,你能帮我吗,如果你能做到这一点和任何样品,你能帮我吗,如果你能做到这一点和任何样品,你能帮我吗,如果你能做到这一点和任何样品,你能帮我吗
@Override
public Drawable getDrawable(String arg0) {
// TODO Auto-generated method stub
int id = 0;
if(arg0.equals("a.png")){
id = R.drawable.a;
}
LevelListDrawable d = new LevelListDrawable();
Drawable empty = getResources().getDrawable(id);
d.addLevel(0, 0, empty);
d.setBounds(0, 0, empty.getIntrinsicWidth(), empty.getIntrinsicHeight());
return d;
}
ImageGetter imageGetter = new ImageGetter() {
@Override
public Drawable getDrawable(String source) {
byte [] encodeByte=Base64.decode("iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",Base64.DEFAULT);
Bitmap bitmap=BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length);
Drawable d = new BitmapDrawable(bitmap);
Log.e("Chk", "Height : "+d.getIntrinsicHeight());
Log.e("Chk", "Width : " + d.getIntrinsicWidth());
return d;
}
};