Skip to content

Commit a8624ef

Browse files
committed
1,完善AlmightyShapeImageView
1 parent 7f424ff commit a8624ef

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,17 @@ public AlmightyShapeImageView(@NonNull Context context, @Nullable AttributeSet a
4747
@Override
4848
protected void onDraw(Canvas canvas) {
4949
if (mShapeResource != null) {
50-
drawShapeClear(canvas);
51-
50+
preDrawShaper(canvas);
5251
drawShape(canvas);
5352
super.onDraw(canvas);
5453
canvas.restore();
55-
56-
5754
} else {
5855
super.onDraw(canvas);
5956
}
6057

6158
}
6259

63-
private void drawShapeClear(Canvas canvas) {
60+
private void preDrawShaper(Canvas canvas) {
6461
if (mShapeScaleType != ShapeScaleType.ALWAYS_FIX_XY){
6562
return;
6663
}
@@ -281,6 +278,15 @@ public void setShapeResource(@DrawableRes int shapeResourceRes) {
281278
setShapeResource(getResources().getDrawable(shapeResourceRes));
282279
}
283280

281+
public ShapeScaleType getShapeScaleType() {
282+
return mShapeScaleType;
283+
}
284+
285+
public void setShapeScaleType(ShapeScaleType shapeScaleType) {
286+
this.mShapeScaleType = shapeScaleType;
287+
invalidate();
288+
}
289+
284290
public enum ShapeScaleType {
285291
FOLLOW_IMAGEVIEW_KEEP_RESOURCE_SCALE(0),FOLLOW_IMAGEVIEW_FULL_IMAGE(1), ALWAYS_FIX_XY(2);
286292

0 commit comments

Comments
 (0)