https://github.com/getactivity/shapeview
Shape 支持在布局中直接定义啦,支持设置阴影,文字渐变色,状态选择器
https://github.com/getactivity/shapeview
android backgroundlibrary button edittext recyclerview shadowlayout shape shapebutton shapeconstraintlayout shapeedittext shapeframelayout shapeimageview shapelinearlayout shaperelativelayout shapetextview shapeview supertextview textview
Last synced: about 2 months ago
JSON representation
Shape 支持在布局中直接定义啦,支持设置阴影,文字渐变色,状态选择器
- Host: GitHub
- URL: https://github.com/getactivity/shapeview
- Owner: getActivity
- License: apache-2.0
- Created: 2021-07-17T07:52:36.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2025-03-06T07:15:19.000Z (3 months ago)
- Last Synced: 2025-04-14T08:16:56.042Z (about 2 months ago)
- Topics: android, backgroundlibrary, button, edittext, recyclerview, shadowlayout, shape, shapebutton, shapeconstraintlayout, shapeedittext, shapeframelayout, shapeimageview, shapelinearlayout, shaperelativelayout, shapetextview, shapeview, supertextview, textview
- Language: Java
- Homepage:
- Size: 19.5 MB
- Stars: 943
- Watchers: 12
- Forks: 90
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# ShapeView 框架
* 项目地址:[Github](https://github.com/getActivity/ShapeView)
* 博客介绍:[震惊,没想到 Shape 也可以这么写](https://www.jianshu.com/p/1288d8873440)
* 可以扫码下载 Demo 进行演示或者测试,如果扫码下载不了的,[点击此处可直接下载](https://github.com/getActivity/ShapeView/releases/download/9.6/ShapeView.apk)


#### 集成步骤
* 如果你的项目 Gradle 配置是在 `7.0 以下`,需要在 `build.gradle` 文件中加入
```groovy
allprojects {
repositories {
// JitPack 远程仓库:https://jitpack.io
maven { url 'https://jitpack.io' }
}
}
```* 如果你的 Gradle 配置是 `7.0 及以上`,则需要在 `settings.gradle` 文件中加入
```groovy
dependencyResolutionManagement {
repositories {
// JitPack 远程仓库:https://jitpack.io
maven { url 'https://jitpack.io' }
}
}
```* 配置完远程仓库后,在项目 app 模块下的 `build.gradle` 文件中加入远程依赖
```groovy
android {
// 支持 JDK 1.8
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
}dependencies {
// ShapeView:https://github.com/getActivity/ShapeView
implementation 'com.github.getActivity:ShapeView:9.6'
// ShapeDrawable:https://github.com/getActivity/ShapeDrawable
implementation 'com.github.getActivity:ShapeDrawable:3.3'
}
```#### AndroidX 兼容
* 如果项目是基于 **AndroidX** 包,请在项目 `gradle.properties` 文件中加入
```text
# 表示将第三方库迁移到 AndroidX
android.enableJetifier = true
```* 如果项目是基于 **Support** 包则不需要加入此配置
#### 框架文档
* Java 代码设置
```java
ShapeButton shapeButton = findViewById(R.id.btn_main_test);
shapeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
shapeButton.getShapeDrawableBuilder()
.setSolidColor(0xFF000000)
.setStrokeColor(0xFF5A8DDF)
// 注意:最后需要调用一下 intoBackground 方法才能生效
.intoBackground();shapeButton.getTextColorBuilder()
.setTextColor(0xFFFFFFFF)
// 注意:最后需要调用一下 intoTextColor 方法才能生效
.intoTextColor();shapeButton.setText("颜色已经改变啦");
}
});
```#### 布局属性大全
* [不同版本的 xml 属性适配请点击这里查看](Adaptive.md)
```xml
```
* 目前支持这些属性的控件有:
* View 的子类:ShapeView、ShapeTextView、ShapeButton、ShapeImageView、ShapeRadioButton、ShapeCheckBox、ShapeEditText
* ViewGroup 的子类:ShapeLinearLayout、ShapeFrameLayout、ShapeRelativeLayout、ShapeConstraintLayout、ShapeRecyclerView、ShapeRadioGroup
#### 框架混淆规则
* 在混淆规则文件 `proguard-rules.pro` 中加入
```text
-keep class com.hjq.shape.** {*;}
```### [常见疑问解答](HelpDoc.md)
### [使用案例文档](UseDemo.md)
#### 框架亮点
* 功能强大:支持设置阴影、边框渐变色、文本渐变色
* 更加便捷:无需新增 Xml 文件,直接定义控件属性即可
* 即时生效:在布局中可实时预览效果,即见所得,无需运行
* 无学习成本:控件属性和原生 Shape 命名保持一致,无需额外学习
* 覆盖范围广:几乎涵盖所有常见的 View 控件,并且控件名称无任何记忆成本
* 支持状态选择器:不仅支持设置背景色的状态选择器,还支持设置文本颜色的状态选择器
#### 作者的其他开源项目
* 安卓技术中台:[AndroidProject](https://github.com/getActivity/AndroidProject)  
* 安卓技术中台 Kt 版:[AndroidProject-Kotlin](https://github.com/getActivity/AndroidProject-Kotlin)  
* 权限框架:[XXPermissions](https://github.com/getActivity/XXPermissions)  
* 吐司框架:[Toaster](https://github.com/getActivity/Toaster)  
* 网络框架:[EasyHttp](https://github.com/getActivity/EasyHttp)  
* 标题栏框架:[TitleBar](https://github.com/getActivity/TitleBar)  
* 悬浮窗框架:[EasyWindow](https://github.com/getActivity/EasyWindow)  
* ShapeDrawable 框架:[ShapeDrawable](https://github.com/getActivity/ShapeDrawable)  
* 语种切换框架:[MultiLanguages](https://github.com/getActivity/MultiLanguages)  
* Gson 解析容错:[GsonFactory](https://github.com/getActivity/GsonFactory)  
* 日志查看框架:[Logcat](https://github.com/getActivity/Logcat)  
* 嵌套滚动布局框架:[NestedScrollLayout](https://github.com/getActivity/NestedScrollLayout)  
* Android 版本适配:[AndroidVersionAdapter](https://github.com/getActivity/AndroidVersionAdapter)  
* Android 代码规范:[AndroidCodeStandard](https://github.com/getActivity/AndroidCodeStandard)  
* Android 资源大汇总:[AndroidIndex](https://github.com/getActivity/AndroidIndex)  
* Android 开源排行榜:[AndroidGithubBoss](https://github.com/getActivity/AndroidGithubBoss)  
* Studio 精品插件:[StudioPlugins](https://github.com/getActivity/StudioPlugins)  
* 表情包大集合:[EmojiPackage](https://github.com/getActivity/EmojiPackage)  
* AI 资源大汇总:[AiIndex](https://github.com/getActivity/AiIndex)  
* 省市区 Json 数据:[ProvinceJson](https://github.com/getActivity/ProvinceJson)  
* Markdown 语法文档:[MarkdownDoc](https://github.com/getActivity/MarkdownDoc)  
#### 微信公众号:Android轮子哥

#### Android 技术 Q 群:10047167
#### 如果您觉得我的开源库帮你节省了大量的开发时间,请扫描下方的二维码随意打赏,要是能打赏个 10.24 :monkey_face:就太:thumbsup:了。您的支持将鼓励我继续创作:octocat:([点击查看捐赠列表](https://github.com/getActivity/Donate))
 
## License
```text
Copyright 2021 Huang JinQunLicensed 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 athttp://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.
```