- 如果你的项目 Gradle 配置是在
7.0 以下,需要在build.gradle文件中加入
allprojects{repositories{// JitPack 远程仓库:https://jitpack.io maven{url 'https://jitpack.io' } } }- 如果你的 Gradle 配置是
7.0 及以上,则需要在settings.gradle文件中加入
dependencyResolutionManagement{repositories{// JitPack 远程仓库:https://jitpack.io maven{url 'https://jitpack.io' } } }- 配置完远程仓库后,在项目 app 模块下的
build.gradle文件中加入远程依赖
android{// 支持 JDK 1.8 compileOptions{targetCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8 } } dependencies{// ShapeDrawable:https://github.com/getActivity/ShapeDrawable implementation 'com.github.getActivity:ShapeDrawable:3.3' }- 通用属性
// 设置 Shape 形状setType(@ShapeTypeLimitintshape) // 设置 Shape 宽度setWidth(intwidth) // 设置 Shape 高度setHeight(intheight) // 设置矩形的圆角大小setRadius(floatradius) setRadius(floattopLeftRadius, floattopRightRadius, floatbottomLeftRadius, floatbottomRightRadius)- 填充色相关
// 设置填充色setSolidColor(@ColorIntintstartColor, @ColorInt int endColor) setSolidColor(@ColorInt int startColor, @ColorInt int centerColor, @ColorInt int endColor) setSolidColor(@ColorInt int... colors) // 设置填充色渐变类型setSolidGradientType(@ShapeGradientTypeLimit int type) // 设置填充色渐变方向setSolidGradientOrientation(ShapeGradientOrientationorientation) // 设置填充色渐变中心 X 点坐标的相对位置(默认值为 0.5)setSolidGradientCenterX(float centerX) // 设置填充色渐变中心 Y 点坐标的相对位置(默认值为 0.5)setSolidGradientCenterY(float centerY) // 设置填充色渐变半径大小setSolidGradientRadius(float radius)- 边框色相关
// 设置边框色setStrokeColor(@ColorIntintstartColor, @ColorInt int endColor) setStrokeColor(@ColorInt int startColor, @ColorInt int centerColor, @ColorInt int endColor) setStrokeColor(@ColorInt int... colors) // 设置边框色渐变方向setStrokeGradientOrientation(ShapeGradientOrientationorientation) // 设置边框大小setStrokeSize(int size) // 设置边框每一节虚线宽度setStrokeDashSize(float dashSize) // 设置边框虚线每一节间隔setStrokeDashGap(float dashGap)- 阴影相关
// 设置阴影颜色setShadowColor(@ColorIntintcolor) // 设置阴影大小setShadowSize(intsize) // 设置阴影水平偏移setShadowOffsetX(intoffsetX) // 设置阴影垂直偏移setShadowOffsetY(intoffsetY)- 圆环相关
// 设置内环的半径大小setRingInnerRadiusSize(intsize) // 设置内环的半径比率setRingInnerRadiusRatio(floatratio) // 设置外环的厚度大小setRingThicknessSize(intsize) // 设置外环的厚度比率setRingThicknessRatio(floatratio)- 线条相关
// 设置线条重心setLineGravity(intlineGravity)- 其他的
// 将当前 Drawable 对象应用到 View 背景,需要调用此 API 设置到 View 背景,否则可能会导致虚线或者阴影无法生效intoBackground(Viewview)相比系统提供的 GradientDrawable 更强大,ShapeDrawable 支持设置阴影(颜色、大小、偏移量)
相比系统提供的 GradientDrawable 更强大,ShapeDrawable 支持单独给边框设置渐变色(渐变色色值、渐变色方向)
相比系统提供的 GradientDrawable 更强大,ShapeDrawable 支持单独给线条设置方向(top、bottom、left、right、start、end 方向都支持)
安卓技术中台:AndroidProject
安卓技术中台 Kt 版:AndroidProject-Kotlin
权限框架:XXPermissions
吐司框架:Toaster
网络框架:EasyHttp
标题栏框架:TitleBar
悬浮窗框架:EasyWindow
ShapeView 框架:ShapeView
语种切换框架:MultiLanguages
Gson 解析容错:GsonFactory
日志查看框架:Logcat
嵌套滚动布局框架:NestedScrollLayout
Android 版本适配:AndroidVersionAdapter
Android 代码规范:AndroidCodeStandard
Android 资源大汇总:AndroidIndex
Android 开源排行榜:AndroidGithubBoss
Studio 精品插件:StudioPlugins
表情包大集合:EmojiPackage
省市区 Json 数据:ProvinceJson
Copyright 2023 Huang JinQun 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. 



