一种可以使用属性替代shape背景的布局,从此告别写shape xml
使用这个布局可以使用属性替代shape背景,避免重复创建大量相似但又细微不同的shape xml
注:编译此项目请直接 clone 父工程 AndroidLibraries
implementation 'com.dreamgyf.android.ui.widget:ShapeLayout:1.1'属性名和shape属性名类似,加上了前缀
-
cornerRadius--- 对应corner标签下的radius属性,圆角 -
cornerTopLeftRadius--- 对应corner标签下的topLeftRadius属性,左上圆角 -
cornerTopRightRadius--- 对应corner标签下的topRightRadius属性,右上圆角 -
cornerBottomRightRadius--- 对应corner标签下的bottomRightRadius属性,右下圆角 -
cornerBottomLeftRadius--- 对应corner标签下的bottomLeftRadius属性,左下圆角
-
gradientStartColor--- 对应gradient标签下的startColor属性,渐变起始颜色 -
gradientCenterColor--- 对应gradient标签下的centerColor属性,渐变中间颜色(可选) -
gradientEndColor--- 对应gradient标签下的endColor属性,渐变结束颜色 -
gradientAngle--- 对应gradient标签下的angle属性,渐变角度,默认为270度,即从上向下 -
gradientType--- 对应gradient标签下的type属性,渐变类型,分别为线性、圆形和扫射,默认为线性 -
gradientCenterX--- 对应gradient标签下的centerX属性,相对X的渐变位置 -
gradientCenterY--- 对应gradient标签下的centerY属性,相对Y的渐变位置 -
gradientRadius--- 对应gradient标签下的gradientRadius属性,渐变颜色的半径注:
gradientType为radial(圆形)的情况下,必须要设置gradientRadius,否则会报错
solid--- 对应solid标签下的color属性,填充颜色
-
strokeWidth--- 对应stroke标签下的width属性,边框粗细 -
strokeColor--- 对应stroke标签下的color属性,边框颜色 -
strokeDashWidth--- 对应stroke标签下的dashWidth属性,虚线边框中,每条线段的长度 -
strokeDashGap--- 对应stroke标签下的dashGap属性,虚线边框中,每条线段之间间隔的长度
