Skip to content

Commit df22813

Browse files
committed
解决设置渐变色时,clickable=“false”失效bug
1 parent 64fb936 commit df22813

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

shadowLibrary/src/main/java/com/lihang/ShadowLayout.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ public void setClickable(boolean clickable) {
120120
changeSwitchClickable();
121121
if (isClickable) {
122122
super.setOnClickListener(onClickListener);
123+
}
124+
125+
if (paint != null) {
126+
gradient(paint);
123127
}
124128
}
125129

@@ -504,6 +508,11 @@ private void initView(Context context, AttributeSet attrs) {
504508

505509
//将画笔附上 渐变色
506510
public void gradient(Paint paint) {
511+
if (!isClickable) {
512+
paint.setShader(null);
513+
return;
514+
}
515+
507516
//左上 x,y leftPadding, topPadding,
508517
//右下 x,y getWidth() - rightPadding, getHeight() - bottomPadding
509518
int[] colors;

0 commit comments

Comments
 (0)