Skip to content

Commit 89a8c21

Browse files
committed
修复无法动态删除渐变色的问题
修复无法动态从渐变色切换成纯色的问题
1 parent c31c20a commit 89a8c21

7 files changed

Lines changed: 21 additions & 12 deletions

File tree

.github/ISSUE_TEMPLATE/issue_template_bug.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ assignees: getActivity
2222

2323
* 出现问题的安卓版本【必填】:请填写出现问题的 Android 版本
2424

25+
* 问题信息的来源渠道【必填】:请填写问题的来源(例如:自己遇到的/Bugly 看到的/用户反馈等等)
26+
2527
#### 请回答
2628

2729
* 是部分机型还是所有机型都会出现【必答】:部分/全部(例如:某为,某 Android 版本会出现)

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Shape 框架
22

3-
* 项目地址:[Github](https://github.com/getActivity/ShapeView)[码云](https://gitee.com/getActivity/ShapeView)
3+
* 项目地址:[Github](https://github.com/getActivity/ShapeView)
44

55
* 博客介绍:[震惊,没想到 Shape 也可以这么写](https://www.jianshu.com/p/1288d8873440)
66

7-
* 可以扫码下载 Demo 进行演示或者测试,如果扫码下载不了的,[点击此处可直接下载](https://github.com/getActivity/ShapeView/releases/download/8.3/ShapeView.apk)
7+
* 可以扫码下载 Demo 进行演示或者测试,如果扫码下载不了的,[点击此处可直接下载](https://github.com/getActivity/ShapeView/releases/download/8.5/ShapeView.apk)
88

99
![](picture/demo_code.png)
1010

@@ -47,11 +47,11 @@ android {
4747
4848
dependencies {
4949
// Shape 框架:https://github.com/getActivity/ShapeView
50-
implementation 'com.github.getActivity:ShapeView:8.3'
50+
implementation 'com.github.getActivity:ShapeView:8.5'
5151
}
5252
```
5353

54-
#### AndroidX
54+
#### AndroidX 兼容
5555

5656
* 如果项目是基于 **AndroidX** 包,请在项目 `gradle.properties` 文件中加入
5757

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
minSdkVersion 16
99
// noinspection ExpiredTargetSdkVersion
1010
targetSdkVersion 28
11-
versionCode 83
12-
versionName "8.3"
11+
versionCode 85
12+
versionName "8.5"
1313
}
1414

1515
// 支持 Java JDK 8

app/src/main/res/layout/activity_main.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@
113113
android:textSize="14sp"
114114
app:shape="rectangle"
115115
app:shape_radius="20dp"
116+
app:shape_endColor="#ED58FF"
117+
app:shape_startColor="#49DAFA"
116118
app:shape_strokeColor="#000000"
117119
app:shape_strokeWidth="1dp" />
118120

@@ -385,7 +387,6 @@
385387
app:shape_textStartColor="#49DAFA" />
386388

387389
<com.hjq.shape.view.ShapeTextView
388-
android:id="@+id/test"
389390
android:layout_width="wrap_content"
390391
android:layout_height="wrap_content"
391392
android:layout_margin="10dp"

library/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ android {
55

66
defaultConfig {
77
minSdkVersion 16
8-
versionCode 83
9-
versionName "8.3"
8+
versionCode 85
9+
versionName "8.5"
1010
}
1111

1212
// 支持 Java JDK 8

library/src/main/java/com/hjq/shape/builder/ShapeDrawableBuilder.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,10 +694,8 @@ public ShapeDrawable convertShapeDrawable(Drawable drawable) {
694694
}
695695

696696
public void intoBackground() {
697+
// 获取到的 Drawable 有可能为空
697698
Drawable drawable = buildBackgroundDrawable();
698-
if (drawable == null) {
699-
return;
700-
}
701699
if (isDashLineEnable() || isShadowEnable()) {
702700
// 需要关闭硬件加速,否则虚线或者阴影在某些手机上面无法生效
703701
mView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

library/src/main/java/com/hjq/shape/drawable/ShapeDrawable.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,14 @@ private boolean ensureValidRect() {
831831

832832
mShadowRect.set(shadowLet, shadowTop, shadowRight, shadowBottom);
833833

834+
if (st.mSolidColors == null) {
835+
mFillPaint.setShader(null);
836+
}
837+
838+
if (st.mStrokeColors == null) {
839+
mStrokePaint.setShader(null);
840+
}
841+
834842
if (st.mSolidColors != null || st.mStrokeColors != null) {
835843
RectF r = mRect;
836844
float x0, x1, y0, y1;

0 commit comments

Comments
 (0)