{"record":{"id":"4f511d099507ff7f","repo":"hdodenhof/CircleImageView","slug":"scaletype-s-not-supported","errorCode":null,"errorMessage":"ScaleType %s not supported.","messagePattern":"ScaleType (.+?) not supported\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"circleimageview/src/main/java/de/hdodenhof/circleimageview/CircleImageView.java","lineNumber":143,"sourceCode":"\n        mBorderPaint.setStyle(Paint.Style.STROKE);\n        mBorderPaint.setAntiAlias(true);\n        mBorderPaint.setColor(mBorderColor);\n        mBorderPaint.setStrokeWidth(mBorderWidth);\n\n        mCircleBackgroundPaint.setStyle(Paint.Style.FILL);\n        mCircleBackgroundPaint.setAntiAlias(true);\n        mCircleBackgroundPaint.setColor(mCircleBackgroundColor);\n\n        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {\n            setOutlineProvider(new OutlineProvider());\n        }\n    }\n\n    @Override\n    public void setScaleType(ScaleType scaleType) {\n        if (scaleType != SCALE_TYPE) {\n            throw new IllegalArgumentException(String.format(\"ScaleType %s not supported.\", scaleType));\n        }\n    }\n\n    @Override\n    public void setAdjustViewBounds(boolean adjustViewBounds) {\n        if (adjustViewBounds) {\n            throw new IllegalArgumentException(\"adjustViewBounds not supported.\");\n        }\n    }\n\n    @SuppressLint(\"CanvasSize\")\n    @Override\n    protected void onDraw(Canvas canvas) {\n        if (mDisableCircularTransformation) {\n            super.onDraw(canvas);\n            return;\n        }\n","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/hdodenhof/CircleImageView/blob/59ee0a11d7199cdeb2d454ebeaaa8396238c418f/circleimageview/src/main/java/de/hdodenhof/circleimageview/CircleImageView.java#L125-L161","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove the android:scaleType attribute from the XML declaration of CircleImageView (the view forces CENTER_CROP itself).","Delete any programmatic setScaleType(...) call on CircleImageView instances; if different scaling is needed, use a plain ImageView instead of this library.","Wrap the call in a guard that only invokes setScaleType when the value equals the supported SCALE_TYPE.","Fork or subclass and relax the check if a non-CENTER_CROP scale type is genuinely required (at the cost of incorrect circular clipping)."],"exampleFix":"// before\n<de.hdodenhof.circleimageview.CircleImageView\n    android:layout_width=\"48dp\"\n    android:layout_height=\"48dp\"\n    android:scaleType=\"fitCenter\" />\n\n// after\n<de.hdodenhof.circleimageview.CircleImageView\n    android:layout_width=\"48dp\"\n    android:layout_height=\"48dp\" />","handlingStrategy":"validation","validationCode":"if (scaleType != ImageView.ScaleType.CENTER_CROP) { // only CENTER_CROP is supported by CircleImageView\n    // skip setScaleType or adjust config\n}","typeGuard":"boolean isSupportedScaleType(ImageView.ScaleType st) { return st == ImageView.ScaleType.CENTER_CROP; }","tryCatchPattern":"try {\n    imageView.setScaleType(scaleType);\n} catch (IllegalArgumentException e) {\n    Log.w(\"CircleImage\", \"Scale type not supported, keeping default\", e);\n}","preventionTips":["Never set android:scaleType on CircleImageView in XML.","Don't apply shared styles or generic ImageView configuration code to CircleImageView.","Treat CircleImageView as fixed to CENTER_CROP; adjust the bitmap, not the view, for different scaling."],"tags":["android","imageview","illegal-argument","library-restriction","ui"],"backgroundTag":"invalid-argument-value","analyzedSha":"59ee0a11d7199cdeb2d454ebeaaa8396238c418f","analyzedAt":"2026-09-06T11:47:14.665Z","contentChangedAt":"2026-09-06T11:47:14.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}