一、 Demo下载地址
先在项目根目录的 build.gradle 的 repositories 添加:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
然后在dependencies添加:
dependencies {
implementation 'com.github.lygttpod:ShapeView:VERSION_CODE'
}
注意:VERSION_CODE为后面的数字,即最新的release版本号
<com.lygttpod.shape.view.ShapeTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="ShapeTextView"
shape:shapeCornersRadius="20dp"
shape:shapeSolidColor="@color/colorAccent"
shape:shapeStrokeColor="@color/colorPrimary"
shape:shapeStrokeDashGap="10dp"
shape:shapeStrokeDashWidth="10dp"
shape:shapeStrokeWidth="2dp" />
shapeTextView.setShapeType(ShapeType.RECTANGLE)
.setShapeSolidColor(getResources().getColor(R.color.red_btn))
.setShapeStrokeColor(getResources().getColor(R.color.gray))
.setShapeStrokeWidth(2)
.setShapeCornersRadius(30f)
.into(shapeTextView)
属性名 | 字段 | 描述 | 默认值 |
---|---|---|---|
shapeType | enum | rectangle、oval、line、ring | rectangle |
shapeSolidColor | color | 填充色 | 无 |
shapeSelectorPressedColor | color | 按下时候的颜色 | 无 |
shapeSelectorDisableColor | color | 不可用显示的颜色 | 无 |
shapeSelectorNormalColor | color | 正常显示的颜色 | 无 |
shapeCornersRadius | dimension | 四个角的圆角半径 | 0dp |
shapeCornersTopLeftRadius | dimension | 左上角的圆角半径 | 0dp |
shapeCornersTopRightRadius | dimension | 右上角的圆角半径 | 0dp |
shapeCornersBottomLeftRadius | dimension | 左下角的圆角半径 | 0dp |
shapeCornersBottomRightRadius | dimension | 右下角的圆角半径 | 0dp |
shapeStrokeWidth | dimension | 边框宽度 | 0dp |
shapeStrokeDashWidth | dimension | 虚线宽度 | 0dp |
shapeStrokeDashGap | dimension | 虚线间隙宽度 | 0dp |
shapeStrokeColor | color | 边框颜色 | 无 |
shapeGradientAngle | enum | left_right、bl_tr、bottom_top、br_tl、right_left、tr_bl、top_bottom、tl_br | left_right |
shapeGradientStartColor | color | 渐变开始颜色 | 无 |
shapeGradientCenterColor | color | 渐变中间颜色 | 无 |
shapeGradientEndColor | color | 渐变结束颜色 | 无 |
shapeUseSelector | bool | 是否使用selector | false |
shapeGradientType | enum | linear | false |
三、更新日志
如果遇到问题或者好的建议,请反馈到:issue、lygttpod@163.com 或者lygttpod@gmail.com
如果觉得对你有用的话,点一下右上的星星赞一下吧!
代码是最好的老师,更多详细用法请查看 demo🐾
Copyright 2022 Allen
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.