表情符號(表情符號)視圖/鍵盤布局的實(shí)現(xiàn)我試圖弄清楚如何在Facebook應(yīng)用程序和谷歌Hangouts應(yīng)用程序上實(shí)現(xiàn)表情符號(表情符號)選擇。我查看SoftKeyboard了Android API示例中的Demo應(yīng)用程序,但這些表情符號視圖的顯示看起來并不像SoftKeyboard。它的外觀和行為更像是自定義Dialog視圖。有沒有人知道這些是如何實(shí)現(xiàn)的?此外,Unicode是發(fā)送表情符號的最佳方式還是有其他選擇?我注意到有些Unicode序列\(zhòng)u1F601不會渲染相應(yīng)的表情符號而是顯示為1:EditText messageInput = (EditText) findViewById(R.id.message_input);messageInput.getText().append("\u1F601");
3 回答

慕仙森
TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超8個贊
我發(fā)現(xiàn)了一個非常有用的表情鍵盤。此鍵盤不使用Unicode序列,而只使用本地圖像資源。我認(rèn)為這種類型的鍵盤只能在此應(yīng)用程序中使用,而不能與其他應(yīng)用程序或操作系統(tǒng)一起使用。
所以我改為ImageView
包含一個TextView
包含Unicode序列的資產(chǎn)。
在交叉引用支持的Unicode序列以及Visual Unicode數(shù)據(jù)庫后,我意識到這\u1F601
是一個32位的Unicode表示,并且16位表示可以設(shè)置為:
EditText messageInput = (EditText) findViewById(R.id.message_input);messageInput.getText().append("\ud83d\ude01");

慕斯709654
TA貢獻(xiàn)1840條經(jīng)驗(yàn) 獲得超5個贊
一個視圖組可見或消失也可以放大,它不會對話。每次初始化情緒時,我總是使用像[happy] = R.drawable.happy這樣的關(guān)鍵值。這是情感的文本而內(nèi)容就像[快樂]
public SpannableString textToImage(String content,Context c){ SpannableString ss = new SpannableString(content); int starts = 0; int end = 0; if(content.indexOf("[", starts) != -1 && content.indexOf("]", end) != -1){ starts = content.indexOf("[", starts); end = content.indexOf("]", end); SharedPreferences shared=c.getSharedPreferences("emotion",0); int resource=shared.getInt(content,0); try { Drawable drawable =c.getResources().getDrawable(resource); if (drawable != null) { drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); ImageSpan span = new ImageSpan(drawable, ImageSpan.ALIGN_BASELINE); ss.setSpan(span, starts,end + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } catch (Exception ex){ } } return ss;}
- 3 回答
- 0 關(guān)注
- 359 瀏覽
添加回答
舉報
0/150
提交
取消