# ShadowLayout
**Repository Path**: cxzwan/ShadowLayout
## Basic Information
- **Project Name**: ShadowLayout
- **Description**: 可定制化阴影的万能阴影布局ShadowLayout 3.0 震撼上线。效果赶超CardView。阴影支持x,y轴偏移,支持阴影扩散程度,支持阴影圆角,支持单边或多边不显示阴影;控件支持动态设置shape和selector(项目里再也不用画shape了);支持随意更改颜色值,支持随意更改颜色值,支持随意更改颜色值。重要的事情说三遍
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2021-05-08
- **Last Updated**: 2021-05-08
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# 万能阴影布局-ShadowLayout
[](https://jitpack.io/#lihangleo2/ShadowLayout)
## 特点功能
嵌套后即可享受阴影,比CardView更好用、更方便也更强大
```
支持定制化阴影:
1. 随意修改阴影颜色值
2. 阴影圆角:可统一设置圆角,也可对某几个角单独设置
3. x,y轴阴影偏移
4. 随意修改阴影扩散程度
5. 隐藏阴影:隐藏某边或多边阴影,或完全隐藏
不止于阴影;系统shape功能:项目中shape、selector、ripple统统拥有。解放你的双手,清空项目drawable文件夹
1. shape样式:pressed(按钮点击)、selected(按钮选择)、ripple(点击水波纹)
2. 背景色设置
3. stroke边框设置
4. 渐变色背景色值
5. 按钮是否可被点击
6. 可绑定textView后,可伴随文案变化,可伴随文案颜色变化
7. 支持设置图片背景,支持图片selector
```
## ShadowLayout动态
* [ShadowLayout3.2.0更新内容,及以往成长](https://github.com/lihangleo2/ShadowLayout/wiki)
* 注意:3.1.8修复issues79,阴影过渡不平滑。老项目升级为3.1.8时,需将limit*2。(如果你没有改变阴影透明度则不存在这个问题,放心使用3.1.7)
* 注意:3.0后修改大量api及规范命名,如果还在用2.0,不方便转移的可查看[ShadowLayout2.0文档](https://github.com/lihangleo2/ShadowLayout/blob/master/README218.md)
## 效果展示
为录制流畅,截图分辨率模糊。可在下方扫描二维码下载,查看真机效果
* ### 1.0功能展示
|基础功能展示|各属性展示|随意更改颜色|
|:---:|:---:|:---:|
|||
* ### 2.0功能更新
|2.1.6新增shape,selector功能|2.1.7isSym属性对比|2.1.8单独更改某圆角大小|
|:---:|:---:|:---:|
||
|
* ### 3.0.1版本来袭
|stroke边框及点击|shape及图片selector|组合使用|
|:---:|:---:|:---:|
||
|
* ### 3.1.0新增ripple及渐变色及3.1.1绑定textView
|3.1.0渐变色及ripple|3.1.1绑定textView|
|:---:|:---:|
||
## Demo
扫描二维码下载demo,下载密码是:123456

## 添加依赖
- 项目build.gradle添加如下
```java
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
```
- app build.gradle添加如下
```java
dependencies {
implementation 'com.github.lihangleo2:ShadowLayout:3.2.0'
}
```
[glide版本冲突终极解决方案](https://github.com/lihangleo2/ShadowLayout/blob/master/GLIDE.md)
## 基本使用
* #### 一、阴影的简单使用
```xml
```
* #### 二、stroke边框的简单使用
```xml
```
* #### 三、shape selector的简单使用
```xml
```
* #### 四、图片 selector的简单使用
```xml
```
如果你觉得麻烦,你还可以这样
```xml
```
* #### 五、渐变色的简单使用
```xml
```
* #### 六、水波纹ripple的使用
```xml
```
* #### 七、绑定textView,伴随文案及颜色变化
```xml
```
## 属性表格(Attributes)
### 一、关于阴影
|name|format|description|
|:---:|:---:|:---:|
|hl_shadowHidden|boolean|是否隐藏阴影(默认false)|
|hl_shadowColor|color|阴影颜色值,如不带透明,默认透明16%|
|hl_shadowLimit|dimension|阴影扩散程度(dp)|
|hl_shadowOffsetX|dimension|x轴的偏移量(dp)|
|hl_shadowOffsetY|dimension|y轴的偏移量(dp)|
|hl_shadowHiddenLeft|boolean|左边的阴影不可见,其他3边同理|
|hl_shadowSymmetry|boolean|控件区域是否对称(默认true)根据此图理解
|
### 二、关于圆角
|name|format|description|
|:---:|:---:|:---:|
|hl_cornerRadius|dimension|包括阴影圆角、shape圆角(dp)|
|hl_cornerRadius_leftTop|dimension|左上圆角,其他角还是hl_cornerRadius值;同理其他3角(dp)|
### 三、关于shape
* #### 3.1、关于shape样式及背景色
|name|format|description|
|:---:|:---:|:---:|
|hl_shapeMode|enum|有3种模式:pressed和selected。和系统shape一样,以及ripple点击水波纹|
|hl_layoutBackground|reference/color|背景色,为false时展示:可以是颜色值,图片以及系统shape样式|
|hl_layoutBackground_true|reference/color|背景色,为true时展示:可以是颜色值,图片以及系统shape样式|
* #### 3.2、关于stroke边框
|name|format|description|
|:---:|:---:|:---:|
|hl_strokeWith|dimension|stroke边框线宽度|
|hl_strokeColor|color|边框颜色值,为false展示|
|hl_strokeColor_true|color|边框颜色值,为true展示|
* #### 3.3、关于渐变色
|name|format|description|
|:---:|:---:|:---:|
|hl_startColor|color|渐变起始颜色(设置渐变色后,hl_layoutBackground属性将无效)|
|hl_centerColor|color|渐变中间颜色(可不填)|
|hl_endColor|color|渐变的终止颜色|
|hl_angle|integer|渐变角度(默认0)|
* #### 3.4、关于绑定textView
|name|format|description|
|:---:|:---:|:---:|
|hl_bindTextView|reference|当前要绑定的textView的id|
|hl_textColor|color|shape为false是展示的文案颜色|
|hl_textColor_true|color|shape为true是展示的文案颜色|
|hl_text|string|shape为false时展示的文案|
|hl_text_true|string|shape为true时展示的文案|
### 四、关于clickable
|name|format|description|
|:---:|:---:|:---:|
|clickable|boolean|设置ShadowLayout是否可以被点击;代码设置:mShadowLayout.setClickable(false);(默认true)|
|hl_layoutBackground_clickFalse|reference/color|Clickable为false时,要展示的图片或颜色。(此属性应当在app:hl_shapeMode="pressed"时生效)|
## 方法表格(Method)
|name|format|description|
|:---:|:---:|:---:|
|setShadowHidden()|boolean|是否隐藏阴影|
|setShadowColor()|color|设置阴影颜色值|
|setShadowLimit()|dimension|设置阴影扩散区域|
|setOffsetX()|dimension|设置阴影的X轴偏移量|
|setOffsetY()|dimension|设置阴影的Y轴偏移量|
|setShadowHiddenTop()|boolean|隐藏上边阴影(同理其他三遍)|
|setCornerRadius()|dimension|设置圆角|
|setLayoutBackground()|color|设置false时的背景颜色值|
|setLayoutBackgroundTrue()|color|设置true时的背景颜色值|
|setStrokeColor()|color|设置false时的边框颜色|
|setStrokeColorTrue()|color|设置true时的边框颜色|
|setClickable()|boolean|设置ShadowLayout是否可以点击|
|setSpecialCorner()|integer|设置ShadowLayout四个角的大小|
## 赞赏
如果你喜欢 ShadowLayout 的功能,感觉 ShadowLayout 帮助到了你,可以点右上角 "Star" 支持一下 谢谢! ^_^
你也还可以扫描下面的二维码~ 请作者喝一杯咖啡。或者遇到工作中比较难实现的需求请作者帮忙。
 
如果在捐赠留言中备注名称,将会被记录到列表中~ 如果你也是github开源作者,捐赠时可以留下github项目地址或者个人主页地址,链接将会被添加到列表中
[捐赠列表](https://github.com/lihangleo2/ShadowLayout/blob/master/friend.md)
## 其他作品
[RichEditTextCopyToutiao](https://github.com/lihangleo2/RichEditTextCopyToutiao)
[mPro](https://github.com/lihangleo2/mPro)
[SmartLoadingView](https://github.com/lihangleo2/SmartLoadingView)
## 关于作者。
Android工作多年了,一直向往大厂。在前进的道路上是孤独的。如果你在学习的路上也感觉孤独,请和我一起。让我们在学习道路上少些孤独
* [关于我的经历](https://mp.weixin.qq.com/s?__biz=MzAwMDA3MzU2Mg==&mid=2247483667&idx=1&sn=1a575ea2c636980e5f4c579d3a73d8ab&chksm=9aefcb26ad98423041c61ad7cbad77f0534495d11fc0a302b9fdd3a3e6b84605cad61d192959&mpshare=1&scene=23&srcid=&sharer_sharetime=1572505105563&sharer_shareid=97effcbe7f9d69e6067a40da3e48344a#rd)
* QQ群: 209010674
(点击图标,可以直接加入)
## Licenses
```
MIT License
Copyright (c) 2019 leo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
```