{"record":{"id":"0239aa226e1f0024","repo":"hdodenhof/CircleImageView","slug":"adjustviewbounds-not-supported","errorCode":null,"errorMessage":"adjustViewBounds not supported.","messagePattern":"adjustViewBounds not supported\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"circleimageview/src/main/java/de/hdodenhof/circleimageview/CircleImageView.java","lineNumber":150,"sourceCode":"        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\n        if (mCircleBackgroundColor != Color.TRANSPARENT) {\n            canvas.drawCircle(mDrawableRect.centerX(), mDrawableRect.centerY(), mDrawableRadius, mCircleBackgroundPaint);\n        }\n\n        if (mBitmap != null) {\n            if (mDrawableDirty && mBitmapCanvas != null) {\n                mDrawableDirty = false;","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/hdodenhof/CircleImageView/blob/59ee0a11d7199cdeb2d454ebeaaa8396238c418f/circleimageview/src/main/java/de/hdodenhof/circleimageview/CircleImageView.java#L132-L168","documentation":"CircleImageView overrides setAdjustViewBounds and throws IllegalArgumentException when called with true, because adjustViewBounds sizing is incompatible with the fixed circular mask the view draws. Only 'false' is accepted (the default). This is a deliberate unsupported-feature guard.","triggerScenarios":"Calling circleImageView.setAdjustViewBounds(true) programmatically, or setting android:adjustViewBounds=\"true\" on the view in XML, which routes through this override during inflation.","commonSituations":"Reusing a shared layout/style that enables adjustViewBounds for regular ImageViews; enabling it hoping the circle will shrink-wrap a smaller bitmap; migrating an ImageView to CircleImageView without removing view-bounds tuning attributes.","solutions":["Remove android:adjustViewBounds=\"true\" from the CircleImageView XML element.","Remove any programmatic setAdjustViewBounds(true) call; control size explicitly with layout_width/layout_height instead.","If dynamic sizing is needed, size the bitmap before display or use layout params, not adjustViewBounds.","Use a plain ImageView if adjustViewBounds behavior is essential (the circular library cannot support it)."],"exampleFix":"// before\n<de.hdodenhof.circleimageview.CircleImageView\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:adjustViewBounds=\"true\" />\n\n// after\n<de.hdodenhof.circleimageview.CircleImageView\n    android:layout_width=\"64dp\"\n    android:layout_height=\"64dp\" />","handlingStrategy":"validation","validationCode":"if (adjustViewBounds) { // do not call setAdjustViewBounds(true) on CircleImageView\n    // remove the call or change sizing approach\n}","typeGuard":"boolean isAdjustViewBoundsSafe(boolean adjustViewBounds) { return !adjustViewBounds; }","tryCatchPattern":"try {\n    imageView.setAdjustViewBounds(true);\n} catch (IllegalArgumentException e) {\n    Log.w(\"CircleImage\", \"adjustViewBounds unsupported; use fixed dimensions\", e);\n}","preventionTips":["Never enable adjustViewBounds on circular image views.","Use explicit dp dimensions or match_parent for CircleImageView sizing.","Audit shared styles/themes for android:adjustViewBounds before applying them to CircleImageView."],"tags":["android","imageview","illegal-argument","unsupported-feature","ui"],"backgroundTag":"unsupported-operation","analyzedSha":"59ee0a11d7199cdeb2d454ebeaaa8396238c418f","analyzedAt":"2026-09-06T11:47:14.665Z","contentChangedAt":"2026-09-06T11:47:14.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}