# BackgroundLibrary
**Repository Path**: hihopeorg/BackgroundLibrary
## Basic Information
- **Project Name**: BackgroundLibrary
- **Description**: 帮助用户开发过程中,不需要自定义View,直接添加标签即可自动生成shape和selector效果
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2021-03-19
- **Last Updated**: 2026-07-17
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# BackgroundLibrary
**本项目是基于开源项目BackgroundLibrary进行ohos的移植和开发的,可以通过项目标签以及github地址(https://github.com/JavaNoober/BackgroundLibrary )追踪到原项目版本**
#### 项目介绍
- 项目名称:BackgroundLibrary
- 所属系列:ohos的第三方组件适配移植
- 功能:用户开发过程中,不需要自定义View,直接添加标签即可自动生成shape和selector效果
- 项目移植状态:完成
- 调用差异:无
- 项目作者和维护人:hihope
- 联系方式:hihope@hoperun.com
- 原项目Doc地址:https://github.com/JavaNoober/BackgroundLibrary
- 原项目基线版本:1.6.5 sha1:b8269931967945ec97a720b98f9d304f4c1859d2
- 编程语言:Java
- 外部库依赖:无
#### 效果
#### 安装教程
方法一:
1. 编译依赖库har包BackgroundLibrary.har。
2. 启动 DevEco Studio,将har包导入工程目录“entry->libs”下。
3. 在moudle级别下的build.gradle文件中添加依赖,在dependences标签中增加对libs目录下har包的引用。
```
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
……
}
```
4. 在导入的har包上点击右键,选择“Add as Library”对包进行引用,选择需要引用的模块,并点击“OK”即引用成功。
方法二:
1. 在工程的build.gradle的allprojects中,添加HAR所在的Maven仓地址
```
repositories {
maven {
url 'http://106.15.92.248:8081/repository/Releases/'
}
}
```
2. 在应用模块的build.gradle的dependencies闭包中,添加如下代码:
```
dependencies {
implementation 'com.noober.background.ohos:backgroundlibrary:1.0.0'
}
```
#### 使用说明
1. 边框+背景+圆角
```xml
```
等同于
```xml
```
2.渐变
```xml
```
等同于
```xml
```
2.点赞效果
```xml
```
等同于
```xml
```
通过代码设置
```java
ShapeElement pressedShape = (ShapeElement) ElementScatter.getInstance(this).parse(ResourceTable.Graphic_shape_gender_green);
ShapeElement unPressedShape = (ShapeElement) ElementScatter.getInstance(this).parse(ResourceTable.Graphic_shape_gender_red);
Element draable1= new DrawableCreator.Builder()
.setPressedDrawable(pressedShape)
.setUnPressedDrawable(unPressedShape)
.build();
```
3.点击文字变色及边框变色
```xml
```
4.设置drawableLeft
```xml
```
5.设置帧动画
```xml
```
#### 版本迭代
- v1.0.0
#### 版权和许可信息
```
Apache License ,version 2.0
```