Skip to content

Commit 874d950

Browse files
committed
1,修改方法名
2,修改readme
1 parent 2fbc7d7 commit 874d950

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,24 @@ ShapeImageView|AlmightyShapeImageView
135135

136136
### 属性一览
137137

138-
|attr|format|description|
139-
|---|:---:|:---:|
140-
|almighty_shape_resource|reference|图形资源|
138+
|attr|format| description |
139+
|---|:---:|:---------------------------------:|
140+
|almighty_shape_resource|reference| 图形资源 |
141141

142142
### 方法
143143

144-
|method|type|description|
145-
|---|:---:|:---:|
146-
|setShapeDrawable|Drawable|图形资源Drawable|
147-
|setShapeDrawable|DrawableRes|图形资源id|
144+
| method |type|description|
145+
|------------------|:---:|:---:|
146+
| setShapeResource |Drawable|图形资源Drawable|
147+
| setShapeResource |DrawableRes|图形资源id|
148+
149+
### 图形资源设置提示
150+
151+
ShapeResource可以是shape,可以是vector,可以是png图片,但是**强烈建议使用vector矢量图形效果更佳**
152+
153+
如果使用是svg资源可以将其转化为vector,详情可以看我的博客:
154+
155+
- [博客使用说明](https://blog.csdn.net/u013077428/article/details/127613904)
148156

149157
# 最后推荐我写的另一个库,轻松实现在应用内点击小图查看大图的动画放大效果
150158

library/src/main/java/com/flyjingfish/shapeimageviewlib/AlmightyShapeImageView.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import androidx.appcompat.widget.AppCompatImageView;
1818

1919
public class AlmightyShapeImageView extends AppCompatImageView {
20-
private Drawable mShapeDrawable;
20+
private Drawable mShapeResource;
2121
private Paint mShapePaint;
2222

2323
public AlmightyShapeImageView(@NonNull Context context) {
@@ -32,7 +32,7 @@ public AlmightyShapeImageView(@NonNull Context context, @Nullable AttributeSet a
3232
super(context, attrs, defStyleAttr);
3333

3434
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AlmightyShapeImageView);
35-
mShapeDrawable = a.getDrawable(R.styleable.AlmightyShapeImageView_almighty_shape_resource);
35+
mShapeResource = a.getDrawable(R.styleable.AlmightyShapeImageView_almighty_shape_resource);
3636
a.recycle();
3737
mShapePaint = new Paint();
3838
mShapePaint.setColor(Color.WHITE);
@@ -43,7 +43,7 @@ public AlmightyShapeImageView(@NonNull Context context, @Nullable AttributeSet a
4343

4444
@Override
4545
protected void onDraw(Canvas canvas) {
46-
if (mShapeDrawable != null) {
46+
if (mShapeResource != null) {
4747
mShapePaint.setXfermode(null);
4848
canvas.saveLayer(new RectF(0, 0, canvas.getWidth(), canvas.getHeight()), mShapePaint, Canvas.ALL_SAVE_FLAG);
4949
drawShape(canvas);
@@ -64,23 +64,23 @@ private void drawShape(Canvas canvas) {
6464
int paddingBottom = getPaddingBottom();
6565
mShapePaint.setXfermode(null);
6666
canvas.saveLayer(new RectF(0, 0, canvas.getWidth(), canvas.getHeight()), mShapePaint, Canvas.ALL_SAVE_FLAG);
67-
mShapeDrawable.setBounds(paddingLeft,paddingTop,width-paddingRight,height-paddingBottom);
68-
mShapeDrawable.draw(canvas);
67+
mShapeResource.setBounds(paddingLeft,paddingTop,width-paddingRight,height-paddingBottom);
68+
mShapeResource.draw(canvas);
6969
mShapePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
7070
canvas.saveLayer(new RectF(0, 0, canvas.getWidth(), canvas.getHeight()), mShapePaint, Canvas.ALL_SAVE_FLAG);
7171
}
7272

7373
public Drawable getShapeDrawable() {
74-
return mShapeDrawable;
74+
return mShapeResource;
7575
}
7676

77-
public void setShapeDrawable(Drawable shapeDrawable) {
78-
this.mShapeDrawable = shapeDrawable;
77+
public void setShapeResource(Drawable shapeResource) {
78+
this.mShapeResource = shapeResource;
7979
invalidate();
8080
}
8181

82-
public void setShapeDrawable(@DrawableRes int shapeDrawableRes) {
83-
setShapeDrawable(getResources().getDrawable(shapeDrawableRes));
82+
public void setShapeResource(@DrawableRes int shapeResourceRes) {
83+
setShapeResource(getResources().getDrawable(shapeResourceRes));
8484
}
8585

8686

0 commit comments

Comments
 (0)