From 0672a6a2864b100d9ba56d42180d90568a7ab65a Mon Sep 17 00:00:00 2001 From: Vince Mi Date: Sun, 12 Jan 2014 01:16:56 -0800 Subject: [PATCH] default scaletype to FIT_CENTER and never null, fixes #27 --- roundedimageview/src/com/makeramen/RoundedDrawable.java | 4 ++-- roundedimageview/src/com/makeramen/RoundedImageView.java | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/roundedimageview/src/com/makeramen/RoundedDrawable.java b/roundedimageview/src/com/makeramen/RoundedDrawable.java index a189d5a..d384c3b 100644 --- a/roundedimageview/src/com/makeramen/RoundedDrawable.java +++ b/roundedimageview/src/com/makeramen/RoundedDrawable.java @@ -28,7 +28,7 @@ public class RoundedDrawable extends Drawable { private boolean mOval = false; private float mBorderWidth = 0; private ColorStateList mBorderColor = ColorStateList.valueOf(DEFAULT_BORDER_COLOR); - private ScaleType mScaleType = ScaleType.FIT_XY; + private ScaleType mScaleType = ScaleType.FIT_CENTER; public RoundedDrawable(Bitmap bitmap) { @@ -336,7 +336,7 @@ public ScaleType getScaleType() { public RoundedDrawable setScaleType(ScaleType scaleType) { if (scaleType == null) { - scaleType = ScaleType.FIT_XY; + scaleType = ScaleType.FIT_CENTER; } if (mScaleType != scaleType) { mScaleType = scaleType; diff --git a/roundedimageview/src/com/makeramen/RoundedImageView.java b/roundedimageview/src/com/makeramen/RoundedImageView.java index c33d545..80c3dd9 100644 --- a/roundedimageview/src/com/makeramen/RoundedImageView.java +++ b/roundedimageview/src/com/makeramen/RoundedImageView.java @@ -55,6 +55,9 @@ public RoundedImageView(Context context, AttributeSet attrs, int defStyle) { int index = a.getInt(R.styleable.RoundedImageView_android_scaleType, -1); if (index >= 0) { setScaleType(sScaleTypeArray[index]); + } else { + // default scaletype to FIT_CENTER + setScaleType(ScaleType.FIT_CENTER); } mCornerRadius = a.getDimensionPixelSize(R.styleable.RoundedImageView_corner_radius, -1);