hdodenhof/CircleImageView · error · IllegalArgumentException
adjustViewBounds not supported.
Error message
adjustViewBounds not supported.
What it means
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.
Source
Thrown at circleimageview/src/main/java/de/hdodenhof/circleimageview/CircleImageView.java:150
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;
}
if (mCircleBackgroundColor != Color.TRANSPARENT) {
canvas.drawCircle(mDrawableRect.centerX(), mDrawableRect.centerY(), mDrawableRadius, mCircleBackgroundPaint);
}
if (mBitmap != null) {
if (mDrawableDirty && mBitmapCanvas != null) {
mDrawableDirty = false;View on GitHub (pinned to 59ee0a11d7)
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).
Example fix
// before
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true" />
// after
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="64dp"
android:layout_height="64dp" /> Defensive patterns
Strategy: validation
Validate before calling
if (adjustViewBounds) { // do not call setAdjustViewBounds(true) on CircleImageView
// remove the call or change sizing approach
} Type guard
boolean isAdjustViewBoundsSafe(boolean adjustViewBounds) { return !adjustViewBounds; } Try / catch
try {
imageView.setAdjustViewBounds(true);
} catch (IllegalArgumentException e) {
Log.w("CircleImage", "adjustViewBounds unsupported; use fixed dimensions", e);
} Prevention
- 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.
When it happens
Trigger: Calling circleImageView.setAdjustViewBounds(true) programmatically, or setting android:adjustViewBounds="true" on the view in XML, which routes through this override during inflation.
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
AI-assisted analysis of hdodenhof/CircleImageView@59ee0a11d7 (2026-09-06).
Data as JSON: /api/errors/0239aa226e1f0024.
Report an issue: GitHub.