# ImageLetterIcon
**Repository Path**: chinasoft4_ohos/ImageLetterIcon
## Basic Information
- **Project Name**: ImageLetterIcon
- **Description**: 实现类似用户联系人通讯录展示功能,支持带边框和字母的圆形、矩形、圆角矩形、图片背景效果功能。
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2021-06-09
- **Last Updated**: 2021-10-25
## Categories & Tags
**Categories**: harmonyos-image
**Tags**: None
## README
# ImageLetterIcon
#### 项目介绍
- 项目名称:ImageLetterIcon
- 所属系列:openharmony的第三方组件适配移植
- 功能:实现类似用户联系人通讯录展示功能,支持带边框和字母的圆形、矩形、圆角矩形、图片背景效果功能。
- 项目移植状态:主功能完成
- 调用差异:无
- 开发版本:sdk6,DevEco Studio 2.2 Beta1
- 基线版本:Release v1.2
#### 效果演示
#### 安装教程
1.在项目根目录下的build.gradle文件中,
```
allprojects {
repositories {
maven {
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
}
}
}
```
2.在entry模块的build.gradle文件中,
```
dependencies {
implementation('com.gitee.chinasoft_ohos:ImageLetterIcon:1.0.0')
......
}
```
在sdk6,DevEco Studio 2.2 Beta1下项目可直接运行
如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件,
并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
#### 使用说明
1、将Image控件添加到指定xml
```
```
2、获取Drawable对象,将drawable对象设置给Image
**获取字母背景对象**
```
TextDrawable drawable = TextDrawable.builder()
.buildRect("A", Color.RED);
```
**获取图片背景对象**
```
RoundedDrawable drawable = RoundedDrawable.builder(pixelMap)
.buildRect("A", Color.RED);
```
**填充背景**
```
Image image = (Image) findComponentById(ResourceTable.Id_imageView);
img.setBackground(drawable);
img.addDrawTask(new Component.DrawTask() {
@Override
public void onDraw(Component component, Canvas canvas) {
drawable.drawToCanvas(canvas);
}
});
```
**属性设置**
```
beginConfig() // 初始配置
width(width) // 宽
height(height) // 高
textColor(color) // 字体颜色
useFont(font) // 字体样式
fontSize(size) // 字体大小
bold() // 是否标记
toUpperCase() // 是否大写
withBorder(thickness) // 边框宽度
withBorderColor(color) // 边框颜色
endConfig() // 结束配置
rect() // 矩形
round() // 圆形
roundRect(radius) // 圆角矩形
```
#### 测试信息
CodeCheck代码测试无异常
CloudTest代码测试无异常
病毒安全检测通过
当前版本demo功能与原组件基本无差异
#### 版本迭代
- 1.0.0
#### 版权和许可信息
- Apache License