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

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

至尊寶的傳說
TA貢獻1789條經驗 獲得超10個贊
一個視圖組可見或消失也可以放大,它不會對話。每次初始化情緒時,我總是使用像[happy] = R.drawable.happy這樣的關鍵值。這是情感的文本而內容就像[快樂]
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 關注
- 807 瀏覽
添加回答
舉報
0/150
提交
取消