README.md 2.6 KB
Newer Older
bluesofy's avatar
bluesofy 已提交
1 2
## AvatarView

bluesofy's avatar
bluesofy 已提交
3
[![](https://jitpack.io/v/bluesofy/AvatarView.svg)](https://jitpack.io/#bluesofy/AvatarView)
bluesofy's avatar
bluesofy 已提交
4

bluesofy's avatar
bluesofy 已提交
5 6 7 8 9 10 11 12 13
多头像显示视图,适用于普通用户头像以及群组多头像显示
[README on GitHub](https://github.com/bluesofy/AvatarView/blob/master/README.md)
  
  
### 效果图  Preview
![Review](https://github.com/bluesofy/AvatarView/blob/master/preview/pic.png)


### 使用说明  Usage
14 15 16 17 18 19 20 21 22 23 24
- 在Gradle中添加JitPack声明
```gradle
allprojects {
    repositories {
        
        maven { url 'https://jitpack.io' }
    }
}
```
- 添加引用
```gradle
bluesofy's avatar
bluesofy 已提交
25 26 27
compile 'com.github.bluesofy:AvatarView:1.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile "com.android.support:support-v4:25.1.0"
28
```
bluesofy's avatar
bluesofy 已提交
29

30
- 代码非原创,在项目 [SImageView](https://github.com/suzeyu1992/SImageView) 的基础上修改,原有的使用方法请通过传送门查看
bluesofy's avatar
bluesofy 已提交
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
- 修改了资源实体,配置灵活,删除了原有的缓存策略,采用 [Glide](https://github.com/bumptech/glide) 加载,新增了显示文字头像,文字和图片混合显示等方法,类似于钉钉的群组头像显示

```java

// 单张文字头像
mSingleAvatarView.setBriefName("张三", Color.WHITE, Color.parseColor("#7FDAD0"));

// 混合头像
mMixAvatarView.setLayoutManager(new WeChatLayoutManager(this));
mMixAvatarView.setDisplayShape(AvatarView.TYPE_RECT);
mMixAvatarView.setErrPicResID(R.mipmap.ic_launcher);
List<ResInfo> infos = new ArrayList<>();
// 文字头像        
infos.add(ResInfo.build()
     .setForceText(true)
     .setBriefText("李四")
     .setTextColor(Color.WHITE)
     .setBgColor(Color.parseColor("#74CAE3")));
// 图片加载错误默认显示文字(如果有设置全局错误图片,则加载错误图片)
infos.add(ResInfo.build()
     .setUrl("http://wrong")
     .setBriefText("王五")
     .setTextColor(Color.WHITE)
     .setBgColor(Color.parseColor("#9AE897")));
// 加载错误强制显示文字
infos.add(ResInfo.build()
     .setForceText(true)
     .setUrl("http://wrong_again")
     .setBriefText("马六")
     .setTextColor(Color.WHITE)
     .setBgColor(Color.parseColor("#9AE897")));
// Url下载图片
infos.add(ResInfo.build()
                 .setUrl("http://www.3dmgame.com/uploads/allimg/141224/270_141224171322_1.jpg"));

mMixAvatarView.setMixRes(infos);

```

bluesofy's avatar
bluesofy 已提交
70
- 更多请查看 [Demo](https://github.com/bluesofy/AvatarView/blob/master/app/src/main/java/cn/byk/pandora/avatarview/sample/MainActivity.java)
bluesofy's avatar
bluesofy 已提交
71 72 73 74 75 76 77 78 79


### 特别鸣谢  Tks to
- [SImageView](https://github.com/suzeyu1992/SImageView)
- [Glide](https://github.com/bumptech/glide)


### 联系方式  Support or Contact
- E-Mail: bluesofy@qq.com
80
- E-Mail: bluesofy@live.cn