Reputation: 2460
I want to implement an android emoji keyboard just using emoji unicode array, without any extra res.
So for the emoji unicode character, I need to get the drawable from android system, if the system doesn't support the charactor, I just ignore this character.
After some basic research,
https://github.com/rockerhieu/emojicon
https://github.com/ankushsachdeva/emojicon
These implements all use self made resources.
use TextView setText
, tv.setText("\u263A");
TextView can show the resource, but how can I get the resource?
Upvotes: 2
Views: 2928
Reputation: 93708
Here's the problem- the system doesn't determine what characters can be displayed. The font does. The font needs to define how to draw every character it will display. That's why you'll see boxes or ? for missing characters- that's the font's default render. There is no method on Android to test if a character will display in a given font (although it would be really nice). And since there's no way to know what font the EditText is using, there's no way to know if a given character is supported. Your best bet is to limit yourself to characters defined in the default Android System font. But even then you're assuming the OEM didn't use a different default font, the user hasn't overridden it, and the app hasn't overridden it. Basically, you're forced to guess and hope.
Upvotes: 3