# BackgroundLibrary
**Repository Path**: andlin/BackgroundLibrary
## Basic Information
- **Project Name**: BackgroundLibrary
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2021-10-18
- **Last Updated**: 2024-09-04
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# BackgroundLibrary
A framework for directly generating shape through Tags, no need to write shape.xml again(通过标签直接生成shape,无需再写shape.xml)
issue回复不及时,可以添加qq群887686934

[English.md](https://github.com/JavaNoober/BackgroundLibrary/blob/master/README-EN.md)
依赖方式:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
implementation "com.android.support:appcompat-v7:$supportVersion"
implementation 'com.github.JavaNoober.BackgroundLibrary:library:1.7.6'
如果项目使用了androidx:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
implementation "androidx.appcompat:appcompat:$supportVersion"
implementation 'com.github.JavaNoober.BackgroundLibrary:libraryx:1.7.6'
## 使用文档
**无需任何代码,直接加入bl标签属性即可,与原生view无缝衔接**,具体使用方法以及属性内容请查看[wiki](https://github.com/JavaNoober/BackgroundLibrary/wiki)
**重要的事情说3遍!!!**
[wiki](https://github.com/JavaNoober/BackgroundLibrary/wiki)
[wiki](https://github.com/JavaNoober/BackgroundLibrary/wiki)
[wiki](https://github.com/JavaNoober/BackgroundLibrary/wiki)
## 示例效果

使用效果完全和原生shape
selector一样,但是只需要直接在xml中加入属性即可,例如
1、边框+背景+圆角
等同于
2、渐变
等同于
3、点击效果

第一个点赞效果:
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginTop="5dp"
app:bl_pressed_drawable="@drawable/circle_like_pressed"
app:bl_unPressed_drawable="@drawable/circle_like_normal" />
就等同于:
通过代码设置:
Drawable drawable4 = new DrawableCreator.Builder().setCornersRadius(dip2px(20))
.setPressedDrawable(ContextCompat.getDrawable(this, R.drawable.circle_like_pressed))
.setUnPressedDrawable(ContextCompat.getDrawable(this, R.drawable.circle_like_normal))
.build();
tv.setClickable(true);
tv.setBackground(drawable4);
第二个按钮效果:
通过代码设置:
Drawable drawable3 = new DrawableCreator.Builder().setCornersRadius(dip2px(20))
.setRipple(true, Color.parseColor("#71C671"))
.setSolidColor(Color.parseColor("#7CFC00"))
.setStrokeColor(Color.parseColor("#8c6822"))
.setStrokeWidth(dip2px(2))
.build();
btn.setBackground(drawable3);
使用其实基本和selector shape一样。
4、点击文字变色

5、点击填充边框变色属性

6、style类似的使用方式
style中不要加入"app:", 直接写属性名即可
7、设置drawableLeft

8、设置帧动画

9、甚至支持直接在xml中设置方法,暂时只支持无参方法,支持父类方法
加入bl_function属性即可,这样控件就增加了finish点击事件,很多时候返回键只是一个finish,我们仅需要加入该属性即可,
当然使用场景还有很多。
如果有什么问题,方便大家交流,创建了一个qq群,群号887686934,欢迎大家加入

## Apache License
Apache License
Copyright [2018] [javakepp]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.