android表情输入键盘,GitHub - UKfire/Emotion: 帮你的Android应用快速集成表情键盘

##Emotion

帮你快速集成Android表情键盘,让你的应用不止文字,让表情跳动起来

##It looks Cool

687474703a2f2f3131352e32392e3131332e3233343a383038302f79792f656d6f74696f6e2e706e67

##Usage

Download ZIP,然后解压,将emoji包添加到自己的项目中,然后再Project Structure设置你app的dependiences,点击+号module dependency将emoji添加进来,接下来你就能在项目中快速集成表情键盘了。

##Sample

先在需要使用表情键盘的xml文件中声明,把它放在最底部,当然该布局文件还需要一个AppcompatEditText来支撑文字和表情输入呀~

android:id="@+id/write_smile_panel"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"

android:visibility="visible">

然后在Activity中,

AppCompatEditText editText = (AppCompatEditText) findViewById(R.id.blogEditText);

SmileLayout smileLayout = (SmileLayout) findViewById(R.id.write_smile_panel);

smileLayout.setVisibility(View.GONE);

//!!!初始化,这句话一定要加

smileLayout.init(editText);

//点击表情后弹出表情键盘并隐藏输入法键盘

emoji.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

hideKeyBoard();

if (smileLayout.getVisibility() == View.GONE)

smileLayout.setVisibility(View.VISIBLE);

else

smileLayout.setVisibility(View.GONE);

}

});

//点击edittext后弹出输入法键盘并隐藏表情键盘

editText.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

smileLayout.setVisibility(View.GONE);

showKeyboard();

}

});

其中的hideKeyBoard方法和showKeyBoard方法如下:

/**

* 隐藏键盘

*/

public void hideKeyBoard() {

if (getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {

if (getCurrentFocus() != null) {

InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

manager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

}

}

}

/**

* 弹出键盘

*/

public void showKeyboard() {

editText.setFocusable(true);

editText.setFocusableInTouchMode(true);

editText.requestFocus();

InputMethodManager inputManager = (InputMethodManager) editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

inputManager.showSoftInput(editText, 0);

}

##写在最后

二珂女神镇楼

欢迎大家访问我的主页二可

687474703a2f2f3131352e32392e3131332e3233343a383038302f79792f382e6a7067

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值