Skip to content

Commit

Permalink
修复无法动态删除渐变色的问题
Browse files Browse the repository at this point in the history
修复无法动态从渐变色切换成纯色的问题
  • Loading branch information
getActivity committed Sep 17, 2022
1 parent c31c20a commit 89a8c21
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/issue_template_bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ assignees: getActivity

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

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

#### 请回答

* 是部分机型还是所有机型都会出现【必答】:部分/全部(例如:某为,某 Android 版本会出现)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Shape 框架

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

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

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

![](picture/demo_code.png)

Expand Down Expand Up @@ -47,11 +47,11 @@ android {
dependencies {
// Shape 框架:https://github.com/getActivity/ShapeView
implementation 'com.github.getActivity:ShapeView:8.3'
implementation 'com.github.getActivity:ShapeView:8.5'
}
```

#### AndroidX
#### AndroidX 兼容

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

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
minSdkVersion 16
// noinspection ExpiredTargetSdkVersion
targetSdkVersion 28
versionCode 83
versionName "8.3"
versionCode 85
versionName "8.5"
}

// 支持 Java JDK 8
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
android:textSize="14sp"
app:shape="rectangle"
app:shape_radius="20dp"
app:shape_endColor="#ED58FF"
app:shape_startColor="#49DAFA"
app:shape_strokeColor="#000000"
app:shape_strokeWidth="1dp" />

Expand Down Expand Up @@ -385,7 +387,6 @@
app:shape_textStartColor="#49DAFA" />

<com.hjq.shape.view.ShapeTextView
android:id="@+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ android {

defaultConfig {
minSdkVersion 16
versionCode 83
versionName "8.3"
versionCode 85
versionName "8.5"
}

// 支持 Java JDK 8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,10 +694,8 @@ public ShapeDrawable convertShapeDrawable(Drawable drawable) {
}

public void intoBackground() {
// 获取到的 Drawable 有可能为空
Drawable drawable = buildBackgroundDrawable();
if (drawable == null) {
return;
}
if (isDashLineEnable() || isShadowEnable()) {
// 需要关闭硬件加速,否则虚线或者阴影在某些手机上面无法生效
mView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,14 @@ private boolean ensureValidRect() {

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

if (st.mSolidColors == null) {
mFillPaint.setShader(null);
}

if (st.mStrokeColors == null) {
mStrokePaint.setShader(null);
}

if (st.mSolidColors != null || st.mStrokeColors != null) {
RectF r = mRect;
float x0, x1, y0, y1;
Expand Down

0 comments on commit 89a8c21

Please sign in to comment.