hdodenhof/CircleImageView · error · IllegalArgumentException

ScaleType %s not supported.

Error message

ScaleType %s not supported.

What it means

CircleImageView intentionally locks the ImageView scale type to CENTER_CROP (its own SCALE_TYPE constant) because circular clipping only renders correctly with that scale type. Any call to setScaleType() with any other value throws IllegalArgumentException. This is an API-design restriction, not a state or environment failure.

Source

Thrown at circleimageview/src/main/java/de/hdodenhof/circleimageview/CircleImageView.java:143

        mBorderPaint.setStyle(Paint.Style.STROKE);
        mBorderPaint.setAntiAlias(true);
        mBorderPaint.setColor(mBorderColor);
        mBorderPaint.setStrokeWidth(mBorderWidth);

        mCircleBackgroundPaint.setStyle(Paint.Style.FILL);
        mCircleBackgroundPaint.setAntiAlias(true);
        mCircleBackgroundPaint.setColor(mCircleBackgroundColor);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            setOutlineProvider(new OutlineProvider());
        }
    }

    @Override
    public void setScaleType(ScaleType scaleType) {
        if (scaleType != SCALE_TYPE) {
            throw new IllegalArgumentException(String.format("ScaleType %s not supported.", scaleType));
        }
    }

    @Override
    public void setAdjustViewBounds(boolean adjustViewBounds) {
        if (adjustViewBounds) {
            throw new IllegalArgumentException("adjustViewBounds not supported.");
        }
    }

    @SuppressLint("CanvasSize")
    @Override
    protected void onDraw(Canvas canvas) {
        if (mDisableCircularTransformation) {
            super.onDraw(canvas);
            return;
        }

View on GitHub (pinned to 59ee0a11d7)

Solutions

  1. Remove the android:scaleType attribute from the XML declaration of CircleImageView (the view forces CENTER_CROP itself).
  2. Delete any programmatic setScaleType(...) call on CircleImageView instances; if different scaling is needed, use a plain ImageView instead of this library.
  3. Wrap the call in a guard that only invokes setScaleType when the value equals the supported SCALE_TYPE.
  4. Fork or subclass and relax the check if a non-CENTER_CROP scale type is genuinely required (at the cost of incorrect circular clipping).

Example fix

// before
<de.hdodenhof.circleimageview.CircleImageView
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:scaleType="fitCenter" />

// after
<de.hdodenhof.circleimageview.CircleImageView
    android:layout_width="48dp"
    android:layout_height="48dp" />
Defensive patterns

Strategy: validation

Validate before calling

if (scaleType != ImageView.ScaleType.CENTER_CROP) { // only CENTER_CROP is supported by CircleImageView
    // skip setScaleType or adjust config
}

Type guard

boolean isSupportedScaleType(ImageView.ScaleType st) { return st == ImageView.ScaleType.CENTER_CROP; }

Try / catch

try {
    imageView.setScaleType(scaleType);
} catch (IllegalArgumentException e) {
    Log.w("CircleImage", "Scale type not supported, keeping default", e);
}

Prevention

When it happens

Trigger: Calling circleImageView.setScaleType(ImageView.ScaleType.FIT_CENTER) (or FIT_XY, MATRIX, CENTER_INSIDE, CENTER, CENTER_CROP passed via XML android:scaleType) with any value other than the library's internal SCALE_TYPE.

Common situations: Copy-pasting a standard ImageView XML layout and adding app:circleimageview attributes but leaving android:scaleType="fitCenter"; programmatically configuring the view with generic ImageView styling code; XML inflation calling setScaleType from android:scaleType attribute.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of hdodenhof/CircleImageView@59ee0a11d7 (2026-09-06). Data as JSON: /api/errors/4f511d099507ff7f. Report an issue: GitHub.