Skip to content

Commit 6fb7eeb

Browse files
committed
抽取 ShapeDrawable 为独立框架
优化 ShapeView 部分属性命名
1 parent b6b4707 commit 6fb7eeb

30 files changed

+477
-1916
lines changed

Adaptive.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424

2525
* 修改 `app:shape_bottomRightRadius` 属性名,请使用 `app:shape_radiusInBottomRight` 代替
2626

27-
* 修改 `app:shape_startColor` 属性名,请使用 `app:shape_solidStartColor` 代替
27+
* 修改 `app:shape_startColor` 属性名,请使用 `app:shape_solidGradientStartColor` 代替
2828

29-
* 修改 `app:shape_centerColor` 属性名,请使用 `app:shape_solidStartColor` 代替
29+
* 修改 `app:shape_centerColor` 属性名,请使用 `app:shape_solidGradientStartColor` 代替
3030

31-
* 修改 `app:shape_endColor` 属性名,请使用 `app:shape_solidEndColor` 代替
31+
* 修改 `app:shape_endColor` 属性名,请使用 `app:shape_solidGradientEndColor` 代替
3232

3333
* 修改 `app:shape_gradientType` 属性名,请使用 `app:shape_solidGradientType` 代替
3434

35-
* 修改 `app:shape_centerX` 属性名,请使用 `app:shape_solidCenterX` 代替
35+
* 修改 `app:shape_centerX` 属性名,请使用 `app:shape_solidGradientCenterX` 代替
3636

37-
* 修改 `app:shape_centerY` 属性名,请使用 `app:shape_solidCenterY` 代替
37+
* 修改 `app:shape_centerY` 属性名,请使用 `app:shape_solidGradientCenterY` 代替
3838

3939
* 修改 `app:shape_gradientRadius` 属性名,请使用 `app:shape_solidGradientRadius` 代替
4040

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ android {
4646
}
4747
4848
dependencies {
49-
// Shape 框架:https://github.com/getActivity/ShapeView
49+
// ShapeView:https://github.com/getActivity/ShapeView
5050
implementation 'com.github.getActivity:ShapeView:9.0'
51+
// ShapeDrawable:https://github.com/getActivity/ShapeDrawable
52+
implementation 'com.github.getActivity:ShapeDrawable:3.0'
5153
}
5254
```
5355

@@ -150,11 +152,11 @@ shapeButton.setOnClickListener(new View.OnClickListener() {
150152
<attr name="shape_solidSelectedColor" format="color" />
151153

152154
<!-- 填充色渐变色起始颜色 -->
153-
<attr name="shape_solidStartColor" format="color" />
155+
<attr name="shape_solidGradientStartColor" format="color" />
154156
<!-- 填充色渐变色中间颜色(可不设置) -->
155-
<attr name="shape_solidCenterColor" format="color" />
157+
<attr name="shape_solidGradientCenterColor" format="color" />
156158
<!-- 填充色渐变色结束颜色 -->
157-
<attr name="shape_solidEndColor" format="color" />
159+
<attr name="shape_solidGradientEndColor" format="color" />
158160

159161
<!-- 填充色渐变方向(仅用于线性渐变。必须是 0-315 范围内的值,并且是 45 的倍数) -->
160162
<attr name="shape_solidGradientOrientation" >
@@ -186,9 +188,9 @@ shapeButton.setOnClickListener(new View.OnClickListener() {
186188
<enum name="sweep" value="2" />
187189
</attr>
188190
<!-- 填充色渐变中心 X 点坐标的相对位置(默认值为 0.5)-->
189-
<attr name="shape_solidCenterX" format="float|fraction" />
191+
<attr name="shape_solidGradientCenterX" format="float|fraction" />
190192
<!-- 填充色渐变中心 Y 点坐标的相对位置(默认值为 0.5)-->
191-
<attr name="shape_solidCenterY" format="float|fraction" />
193+
<attr name="shape_solidGradientCenterY" format="float|fraction" />
192194
<!-- 填充色渐变色半径(仅用于径向渐变) -->
193195
<attr name="shape_solidGradientRadius" format="float|fraction|dimension" />
194196

@@ -206,11 +208,11 @@ shapeButton.setOnClickListener(new View.OnClickListener() {
206208
<attr name="shape_strokeSelectedColor" format="color" />
207209

208210
<!-- 边框色渐变色起始颜色 -->
209-
<attr name="shape_strokeStartColor" format="color" />
211+
<attr name="shape_strokeGradientStartColor" format="color" />
210212
<!-- 边框渐变色中间颜色(可不设置) -->
211-
<attr name="shape_strokeCenterColor" format="color" />
213+
<attr name="shape_strokeGradientCenterColor" format="color" />
212214
<!-- 边框渐变色结束颜色 -->
213-
<attr name="shape_strokeEndColor" format="color" />
215+
<attr name="shape_strokeGradientColor" format="color" />
214216

215217
<!-- 边框色渐变方向(必须是 0-315 范围内的值,并且是 45 的倍数) -->
216218
<attr name="shape_strokeGradientOrientation" >

UseDemo.md

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@
7979
android:textColor="@android:color/black"
8080
android:textSize="14sp"
8181
app:shape_radius="20dp"
82-
app:shape_solidEndColor="#ED58FF"
83-
app:shape_solidStartColor="#49DAFA"
82+
app:shape_solidGradientEndColor="#ED58FF"
83+
app:shape_solidGradientStartColor="#49DAFA"
8484
app:shape_strokeColor="#000000"
8585
app:shape_strokeSize="1dp"
8686
app:shape_type="rectangle" />
@@ -116,10 +116,10 @@
116116
android:textColor="@android:color/white"
117117
android:textSize="14sp"
118118
app:shape_radius="20dp"
119-
app:shape_solidEndColor="#ED58FF"
119+
app:shape_solidGradientEndColor="#ED58FF"
120120
app:shape_solidGradientOrientation="topToBottom"
121121
app:shape_solidPressedColor="#5A8DDF"
122-
app:shape_solidStartColor="#49DAFA"
122+
app:shape_solidGradientStartColor="#49DAFA"
123123
app:shape_type="rectangle" />
124124

125125
<com.hjq.shape.view.ShapeButton
@@ -133,11 +133,11 @@
133133
android:textColor="@android:color/black"
134134
android:textSize="14sp"
135135
app:shape_radius="20dp"
136-
app:shape_strokeEndColor="#f08833"
136+
app:shape_strokeGradientColor="#f08833"
137137
app:shape_strokeGradientOrientation="topToBottom"
138138
app:shape_strokePressedColor="@android:color/black"
139139
app:shape_strokeSize="2dp"
140-
app:shape_strokeStartColor="#fefa54"
140+
app:shape_strokeGradientStartColor="#fefa54"
141141
app:shape_type="rectangle" />
142142

143143
<com.hjq.shape.view.ShapeButton
@@ -151,15 +151,15 @@
151151
android:textColor="@android:color/white"
152152
android:textSize="14sp"
153153
app:shape_radius="20dp"
154-
app:shape_solidEndColor="#ED58FF"
154+
app:shape_solidGradientEndColor="#ED58FF"
155155
app:shape_solidGradientOrientation="topToBottom"
156156
app:shape_solidPressedColor="#5A8DDF"
157-
app:shape_solidStartColor="#49DAFA"
158-
app:shape_strokeEndColor="#f08833"
157+
app:shape_solidGradientStartColor="#49DAFA"
158+
app:shape_strokeGradientColor="#f08833"
159159
app:shape_strokeGradientOrientation="topToBottom"
160160
app:shape_strokePressedColor="@android:color/black"
161161
app:shape_strokeSize="2dp"
162-
app:shape_strokeStartColor="#fefa54"
162+
app:shape_strokeGradientStartColor="#fefa54"
163163
app:shape_type="rectangle" />
164164
```
165165

@@ -304,8 +304,8 @@
304304
app:shape_radius="10dp"
305305
app:shape_shadowColor="#99000000"
306306
app:shape_shadowSize="10dp"
307-
app:shape_solidEndColor="#f08833"
308-
app:shape_solidStartColor="#fefa54"
307+
app:shape_solidGradientEndColor="#f08833"
308+
app:shape_solidGradientStartColor="#fefa54"
309309
app:shape_type="rectangle" />
310310
```
311311

@@ -544,12 +544,12 @@
544544
android:text="矩形-垂直线性渐变"
545545
android:textColor="@android:color/black"
546546
android:textSize="14sp"
547-
app:shape_solidCenterColor="#8000ff00"
548-
app:shape_solidCenterX="0.5"
549-
app:shape_solidCenterY="0.4"
550-
app:shape_solidEndColor="#1000ff00"
547+
app:shape_solidGradientCenterColor="#8000ff00"
548+
app:shape_solidGradientCenterX="0.5"
549+
app:shape_solidGradientCenterY="0.4"
550+
app:shape_solidGradientEndColor="#1000ff00"
551551
app:shape_solidGradientOrientation="topToBottom"
552-
app:shape_solidStartColor="#ff00ff00"
552+
app:shape_solidGradientStartColor="#ff00ff00"
553553
app:shape_strokeColor="#ffff0000"
554554
app:shape_strokeSize="1dp"
555555
app:shape_type="rectangle" />
@@ -563,12 +563,12 @@
563563
android:text="矩形-水平线性渐变"
564564
android:textColor="@android:color/black"
565565
android:textSize="14sp"
566-
app:shape_solidCenterColor="#8000ff00"
567-
app:shape_solidCenterX="0.5"
568-
app:shape_solidCenterY="0.5"
569-
app:shape_solidEndColor="#ff00ff00"
566+
app:shape_solidGradientCenterColor="#8000ff00"
567+
app:shape_solidGradientCenterX="0.5"
568+
app:shape_solidGradientCenterY="0.5"
569+
app:shape_solidGradientEndColor="#ff00ff00"
570570
app:shape_solidGradientOrientation="leftToRight"
571-
app:shape_solidStartColor="#1000ff00"
571+
app:shape_solidGradientStartColor="#1000ff00"
572572
app:shape_strokeColor="#ffff0000"
573573
app:shape_strokeSize="1dp"
574574
app:shape_type="rectangle" />
@@ -582,12 +582,12 @@
582582
android:text="矩形-对角线线性渐变"
583583
android:textColor="@android:color/black"
584584
android:textSize="14sp"
585-
app:shape_solidCenterColor="#8000ff00"
586-
app:shape_solidCenterX="0.5"
587-
app:shape_solidCenterY="0.5"
588-
app:shape_solidEndColor="#1000ff00"
585+
app:shape_solidGradientCenterColor="#8000ff00"
586+
app:shape_solidGradientCenterX="0.5"
587+
app:shape_solidGradientCenterY="0.5"
588+
app:shape_solidGradientEndColor="#1000ff00"
589589
app:shape_solidGradientOrientation="bottomLeftToTopRight"
590-
app:shape_solidStartColor="#ff00ff00"
590+
app:shape_solidGradientStartColor="#ff00ff00"
591591
app:shape_strokeColor="#ffff0000"
592592
app:shape_strokeSize="1dp"
593593
app:shape_type="rectangle" />
@@ -601,13 +601,13 @@
601601
android:text="矩形-径向渐变"
602602
android:textColor="@android:color/black"
603603
android:textSize="14sp"
604-
app:shape_solidCenterX="0.5"
605-
app:shape_solidCenterY="0.5"
606-
app:shape_solidEndColor="#ff00ff00"
604+
app:shape_solidGradientCenterX="0.5"
605+
app:shape_solidGradientCenterY="0.5"
606+
app:shape_solidGradientEndColor="#ff00ff00"
607607
app:shape_solidGradientOrientation="leftToRight"
608608
app:shape_solidGradientRadius="20dp"
609609
app:shape_solidGradientType="radial"
610-
app:shape_solidStartColor="#0000ff00"
610+
app:shape_solidGradientStartColor="#0000ff00"
611611
app:shape_strokeColor="#ffff0000"
612612
app:shape_strokeSize="1dp"
613613
app:shape_type="rectangle" />
@@ -621,12 +621,12 @@
621621
android:text="矩形-扫描渐变"
622622
android:textColor="@android:color/black"
623623
android:textSize="14sp"
624-
app:shape_solidCenterX="0.5"
625-
app:shape_solidCenterY="0.5"
626-
app:shape_solidEndColor="#0000ff00"
624+
app:shape_solidGradientCenterX="0.5"
625+
app:shape_solidGradientCenterY="0.5"
626+
app:shape_solidGradientEndColor="#0000ff00"
627627
app:shape_solidGradientOrientation="leftToRight"
628628
app:shape_solidGradientType="sweep"
629-
app:shape_solidStartColor="#ff00ff00"
629+
app:shape_solidGradientStartColor="#ff00ff00"
630630
app:shape_strokeColor="#ffff0000"
631631
app:shape_strokeSize="1dp"
632632
app:shape_type="rectangle" />
@@ -683,13 +683,13 @@
683683
android:text="圆-线性渐变"
684684
android:textColor="@android:color/black"
685685
android:textSize="14sp"
686-
app:shape_solidCenterColor="#80ff0000"
687-
app:shape_solidCenterX="0.5"
688-
app:shape_solidCenterY="0.8"
689-
app:shape_solidEndColor="#ffff0000"
686+
app:shape_solidGradientCenterColor="#80ff0000"
687+
app:shape_solidGradientCenterX="0.5"
688+
app:shape_solidGradientCenterY="0.8"
689+
app:shape_solidGradientEndColor="#ffff0000"
690690
app:shape_solidGradientOrientation="topToBottom"
691691
app:shape_solidGradientType="linear"
692-
app:shape_solidStartColor="#00ff0000"
692+
app:shape_solidGradientStartColor="#00ff0000"
693693
app:shape_type="oval" />
694694

695695
<com.hjq.shape.view.ShapeTextView
@@ -701,13 +701,13 @@
701701
android:text="圆-径向渐变"
702702
android:textColor="@android:color/black"
703703
android:textSize="14sp"
704-
app:shape_solidCenterColor="#80ff0000"
705-
app:shape_solidCenterX="0.5"
706-
app:shape_solidCenterY="0.5"
707-
app:shape_solidEndColor="#10ff0000"
704+
app:shape_solidGradientCenterColor="#80ff0000"
705+
app:shape_solidGradientCenterX="0.5"
706+
app:shape_solidGradientCenterY="0.5"
707+
app:shape_solidGradientEndColor="#10ff0000"
708708
app:shape_solidGradientRadius="80dp"
709709
app:shape_solidGradientType="radial"
710-
app:shape_solidStartColor="#ffff0000"
710+
app:shape_solidGradientStartColor="#ffff0000"
711711
app:shape_type="oval" />
712712

713713
<com.hjq.shape.view.ShapeTextView
@@ -719,13 +719,13 @@
719719
android:text="圆-扫描渐变"
720720
android:textColor="@android:color/black"
721721
android:textSize="14sp"
722-
app:shape_solidCenterColor="#80ff0000"
723-
app:shape_solidCenterX="0.5"
724-
app:shape_solidCenterY="0.6"
725-
app:shape_solidEndColor="#20ff0000"
722+
app:shape_solidGradientCenterColor="#80ff0000"
723+
app:shape_solidGradientCenterX="0.5"
724+
app:shape_solidGradientCenterY="0.6"
725+
app:shape_solidGradientEndColor="#20ff0000"
726726
app:shape_solidGradientRadius="20dp"
727727
app:shape_solidGradientType="sweep"
728-
app:shape_solidStartColor="#ffff0000"
728+
app:shape_solidGradientStartColor="#ffff0000"
729729
app:shape_type="oval" />
730730
```
731731

@@ -788,11 +788,11 @@
788788
android:textSize="14sp"
789789
app:shape_ringInnerRadiusRatio="4"
790790
app:shape_ringThicknessRatio="4"
791-
app:shape_solidCenterColor="#80ff0000"
792-
app:shape_solidEndColor="#ffff0000"
791+
app:shape_solidGradientCenterColor="#80ff0000"
792+
app:shape_solidGradientEndColor="#ffff0000"
793793
app:shape_solidGradientOrientation="bottomLeftToTopRight"
794794
app:shape_solidGradientType="linear"
795-
app:shape_solidStartColor="#00ff0000"
795+
app:shape_solidGradientStartColor="#00ff0000"
796796
app:shape_type="ring" />
797797

798798
<com.hjq.shape.view.ShapeTextView
@@ -806,10 +806,10 @@
806806
android:textSize="14sp"
807807
app:shape_ringInnerRadiusRatio="4"
808808
app:shape_ringThicknessRatio="4"
809-
app:shape_solidCenterColor="#80ff0000"
810-
app:shape_solidEndColor="#00ff0000"
809+
app:shape_solidGradientCenterColor="#80ff0000"
810+
app:shape_solidGradientEndColor="#00ff0000"
811811
app:shape_solidGradientType="sweep"
812-
app:shape_solidStartColor="#ffff0000"
812+
app:shape_solidGradientStartColor="#ffff0000"
813813
app:shape_type="ring" />
814814
```
815815

0 commit comments

Comments
 (0)