LQREmojiLibrary

一个超级牛逼的表情库,可使用表情及贴图功能,方便好用,抽离图片加载接口,让开发者自己选择图片加载工具。

码云:

https://git.oschina.net/CSDNLQR/LQREmojiLibrary

GitHub:

https://github.com/GitLqr/LQREmojiLibrary

一、简述

这个库相当牛逼,好用。这个库相当牛逼,好用。这个库相当牛逼,好用。好了,接下来直接看效果图吧:

DemoApp下载

二、引用初始化

1、在自己项目中添加本项目依赖:

compile 'com.lqr.emoji:library:1.0.2'

2、初始化

使用本库必须在自定义的Application中使用LQREmotionKit对库进行初始化,LQREmotionKit提供了四种初始化方法,请根据自己的需要选择。

*使用前需要注意以下几点:

  1. 本库抽离出了图片加载接口,可让开发者自己选择图片加载工具(如:Glide、UIL等),所以使用本库必须实现IImageLoader接口。
  2. 本库支持设置贴图的存放路径,这意味着开发者可以根据自己项目需求修改贴图的存放位置,并且支持贴图自定义。默认的贴图存放在/data/data/包名/files/stickers 目录下。

1)不带IImageLoader的init()

public static void init(Context context)public static void init(Context context, String stickerPath)

2)带IImageLoader的init()

public static void init(Context context, IImageLoader imageLoader)public static void init(Context context, String stickerPath, IImageLoader imageLoader)

3)示例

public class App extends Application {@Overridepublic void onCreate() {super.onCreate();LQREmotionKit.init(this, new IImageLoader() {@Overridepublic void displayImage(Context context, String path, ImageView imageView) {Glide.with(context).load(path).centerCrop().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(imageView);}});}
}

三、表情功能集成

1、布局中使用EmotionLayout控件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><!--内容区--><LinearLayoutandroid:id="@+id/llContent"android:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:orientation="vertical">...这里一般是放消息列表,和内容输入框等控件...</LinearLayout><!--表情区--><com.lqr.emoji.EmotionLayoutandroid:id="@+id/elEmotion"android:layout_width="match_parent"android:layout_height="270dp"android:visibility="gone"/></LinearLayout>

2、实现输入框图文混排

1)将内容输入框交给EmotionLayout管理(强烈建议!!!)

mElEmotion.attachEditText(mEtContent);

2)实现IEmotionSelectedListener接口,手动实现图文混排(有自己的实现方式的,可以采用这种方式)

mElEmotion.setEmotionSelectedListener(new IEmotionSelectedListener() {@Overridepublic void onEmojiSelected(String key) {if (mEtContent == null)return;Editable editable = mEtContent.getText();if (key.equals("/DEL")) {mEtContent.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));} else {int start = mEtContent.getSelectionStart();int end = mEtContent.getSelectionEnd();start = (start < 0 ? 0 : start);end = (start < 0 ? 0 : end);editable.replace(start, end, key);int editEnd = mEtContent.getSelectionEnd();MoonUtils.replaceEmoticons(LQREmotionKit.getContext(), editable, 0, editable.toString().length());mEtContent.setSelection(editEnd);}}@Overridepublic void onStickerSelected(String categoryName, String stickerName, String stickerBitmapPath) {}
});

3、实现内容区与表情区仿微信切换效果

private EmotionKeyboard mEmotionKeyboard;private void initEmotionKeyboard() {mEmotionKeyboard = EmotionKeyboard.with(this);mEmotionKeyboard.bindToContent(mLlContent);mEmotionKeyboard.bindToEmotionButton(mIvEmo);mEmotionKeyboard.bindToEditText(mEtContent);mEmotionKeyboard.setEmotionLayout(mElEmotion);
}

4、效果

经过上面几步,就可以实现以下效果了:

四、贴图功能集成

1、设置贴图的存放位置

这一步可略过,不设置的话,贴图的默认存放位置是 /data/data/包名/files/stickers ,可通过LQREmotionKit.getStickerPath()获得。

贴图的存放位置只能通过LQREmotionKit的init()来设置:

LQREmotionKit.init(this, Environment.getExternalStorageDirectory().getAbsolutePath()+ File.separator+"sticker");LQREmotionKit.init(this, Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "sticker", new IImageLoader() {@Overridepublic void displayImage(Context context, String path, ImageView imageView) {Glide.with(context).load(path).centerCrop().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(imageView);}});

2、将贴图下载到指定贴图的存放位置

1)自带贴图

本库支持 集成默认贴图,可将贴图按规则放置在assets的sticker目录下,当程序启动时,会自动将assets的sticker目录下所有的贴图复制到贴图的存放位置。

2)网络下载贴图

//得到贴图的存放位置
String stickerPath = LQREmotionKit.getStickerPath();
...
网络下载(这里不同项目实现方式不同,请根据自己的项目实现该部分代码)
...

3、监听用户点击贴图事件

mElEmotion.setEmotionSelectedListener(new IEmotionSelectedListener() {@Overridepublic void onEmojiSelected(String key) {}@Overridepublic void onStickerSelected(String categoryName, String stickerName, String stickerBitmapPath) {String stickerPath = stickerBitmapPath;...发送图片...}
});

4、效果

经过上面几步,就可以实现以下效果了:

五、拓展按钮的控制

1、设置表情控件的拓展按钮

默认表情控件的底部Tab是不显示“添加”按钮和“设置”按钮的,如果需要,可通过以下代码进行控制。

mElEmotion.setEmotionAddVisiable(true);
mElEmotion.setEmotionSettingVisiable(true);
mElEmotion.setEmotionExtClickListener(new IEmotionExtClickListener() {@Overridepublic void onEmotionAddClick(View view) {Toast.makeText(getApplicationContext(), "add", Toast.LENGTH_SHORT).show();}@Overridepublic void onEmotionSettingClick(View view) {Toast.makeText(getApplicationContext(), "setting", Toast.LENGTH_SHORT).show();}
});

2、效果

高仿微信表情控件 -- LQREmojiLibrary相关推荐

  1. android+高仿视频录制,Android高仿微信拍照控件,实战推荐!

    原标题:Android高仿微信拍照控件,实战推荐! 作者:陈嘉桐 转自:ttps://github.com/CJT2325 控件介绍 不知道是不是在微信更新到6.0版本之后,微信将它的拍照和录制视频的 ...

  2. java使用微信表情代码_iOS高仿微信表情输入功能代码分享

    最近项目需求,要实现一个类似微信的的表情输入,于是把微信的表情扒拉出来,实现了一把.可以从这里下载源码.看起来表情输入没有多少东西,不外乎就是用NSTextAttachment来实现图文混排,结果在实 ...

  3. android高仿微信表情输入与键盘输入详解-解决跳闪与表情切换问题

    最近公司在项目上要使用到表情与键盘的切换输入,自己实现了一个,还是存在些缺陷,比如说键盘与表情切换时出现跳闪问题,这个相当困扰我,不过所幸在Github(其中一个不错的开源项目是https://git ...

  4. android高仿微信表情输入与键盘输入详解

    转载请注明出处: http://blog.csdn.net/javazejian/article/details/52126391   最近公司在项目上要使用到表情与键盘的切换输入,自己实现了一个,还 ...

  5. android高仿微信表情输入与键盘输入(详细实现分析)

    转载请注明出处(请尊重原创!谢谢~): http://blog.csdn.net/javazejian/article/details/52126391 出自[zejian的博客]   表情与键盘的切 ...

  6. android 调出键盘表情_android高仿微信表情输入与键盘输入代码(详细实现分析)

    表情与键盘的切换输入大部分IM都会需要到,之前自己实现了一个,还是存在些缺陷,比如说键盘与表情切换时出现跳闪问题,这个困扰了我些时间,不过所幸在Github(其代码整体结构很不错)并且在论坛上找些解决 ...

  7. (转)Android高仿微信表情输入与键盘输入(详细实现分析)

    原地址:http://blog.csdn.net/javazejian/article/details/52126391 转载请注明出处(请尊重原创!谢谢~):  http://blog.csdn.n ...

  8. 高仿QQ顶部控件之IOS SegmentView

    经常会看到QQ上面有一个 消息和电话 的顶部面板,这个空间是IOS7的分段控制,android中没有这个控件, 今天在威哥的微信公众号中成功gank到这个自定义控件的实现,下面跟着尝试一波. 首先是定 ...

  9. android高仿美团筛选控件,Android高仿美团首页分类按钮

    惯例,先上GIF 栗子.gif更新v1.1版本 2017-6-2 11:55:30 详见github 一.使用姿势 1.引入(使用Gradle或者Maven) 1)Gradleallprojects  ...

  10. android 调出键盘表情_Android高仿微信表情输入与键盘输入详解

    使用到表情与键盘的切换输入,需要多表情的只需要实现自己的表情fragment界面,然后根据工厂类获取即可,上图看效果: 效果还不错吧,哈哈.下面开始介绍: 本篇主要分析的核心类EmotionKeybo ...

最新文章

  1. DevOps时代测试应该如何应对?
  2. 按需生产 ,我们准备好了吗?
  3. 笔记本暗屏维修多少钱_电视机维修|维修电视机多少钱?电视机黑屏
  4. boost::fusion::set用法的测试程序
  5. CGGeometry基础
  6. IoT -- (三) 2018 Top物联网项目排名
  7. SQLite学习总结(3)——SQLite命令及语法
  8. 微软“杀”不死的数据库软件
  9. hive报错(1)MoveTask
  10. 使用C语言编程求解: 1 - 1/2 + 1/3 - 1/4 + 1/5 - ... + 1/99 - 1/100 的值。
  11. 【博士后招聘】浙江大学杨杰课题组-医学AI/大数据分析/自然语言处理
  12. (Demo3D 学习笔记)案例1:自创组件,可以一键自动连接场景中的其他相关组件
  13. Android开发艺术探索 第一章 Activity的生命周期和启动模式
  14. 2021-03-13 java八大基本数据类型
  15. TCP,UDP,IP,数据链路层头部详解
  16. 角色游戏二(NPC对话)
  17. Unity 【Content Size Fitter】- 聊天气泡自动适配Text文本框大小
  18. 小程序实现扫码识别二维码内容
  19. Gamma Correction/Gamma校正/灰度校正/亮度校正(已更正) - 部分 DCC 中的线性工作流配置
  20. 项目管理进阶--软件开发项目中的团队组成

热门文章

  1. android调用webservice,Android开发调用WebService的方法示例
  2. Java使用WebService调用远程服务wsdl的方法,搭建一个demo,简单易用的教程
  3. Greenplum集群扩容总结
  4. android shell卸载应用程序,adb shell删除系统apk
  5. 关于jmeter客户端实现中HttpClient4与Java的区别
  6. Java并发练习:无锁编程
  7. u深度制作win10系统安装盘教程
  8. 阿里云搭建 ftp 服务器
  9. Linux进程之如何查看进程详情?
  10. 被 onnx.checker.check_model 检查出的常见错误