Tencent/QMUI_Android · error · IllegalArgumentException
不支持adjustViewBounds
Error message
不支持adjustViewBounds
What it means
QMUIRadiusImageView computes its rounded-corner/circle shape from the exact measured dimensions, which is incompatible with ImageView's adjustViewBounds scaling. Overriding setAdjustViewBounds, it throws IllegalArgumentException if you try to enable it (disabling is silently allowed).
Source
Thrown at qmui/src/main/java/com/qmuiteam/qmui/widget/QMUIRadiusImageView.java:139
}
mIsTouchSelectModeEnabled = array.getBoolean(
R.styleable.QMUIRadiusImageView_qmui_is_touch_select_mode_enabled, true);
mIsCircle = array.getBoolean(R.styleable.QMUIRadiusImageView_qmui_is_circle, false);
if (!mIsCircle) {
mIsOval = array.getBoolean(R.styleable.QMUIRadiusImageView_qmui_is_oval, false);
}
if (!mIsOval) {
mCornerRadius = array.getDimensionPixelSize(
R.styleable.QMUIRadiusImageView_qmui_corner_radius, 0);
}
array.recycle();
}
@Override
public void setAdjustViewBounds(boolean adjustViewBounds) {
if (adjustViewBounds) {
throw new IllegalArgumentException("不支持adjustViewBounds");
}
}
public void setBorderWidth(int borderWidth) {
if (mBorderWidth != borderWidth) {
mBorderWidth = borderWidth;
invalidate();
}
}
public void setBorderColor(@ColorInt int borderColor) {
if (mBorderColor != borderColor) {
mBorderColor = borderColor;
invalidate();
}
}
public void setCornerRadius(int cornerRadius) {View on GitHub (pinned to 026e7d4866)
Solutions
- Remove android:adjustViewBounds="true" from the XML and drop setAdjustViewBounds(true) calls.
- Use scaleType (e.g. centerCrop or fitCenter) instead of adjustViewBounds for scaling.
- Constrain the view size with layout_width/height or fixed dp dimensions so rounding works.
- If dynamic sizing is required, use a plain ImageView with a rounded outline (ViewOutlineProvider) instead of QMUIRadiusImageView.
Example fix
// before
<com.qmuiteam.qmui.widget.QMUIRadiusImageView
android:adjustViewBounds="true" ... />
// after
<com.qmuiteam.qmui.widget.QMUIRadiusImageView
android:scaleType="centerCrop"
app:qmui_corner_radius="8dp" ... /> Defensive patterns
Strategy: validation
Validate before calling
// only call when you intend to disable (false is accepted)
if (adjustViewBounds) {
throw new IllegalArgumentException("QMUIRadiusImageView does not support adjustViewBounds");
} Try / catch
try {
imageView.setAdjustViewBounds(true);
} catch (IllegalArgumentException e) {
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
} Prevention
- Never set android:adjustViewBounds on QMUIRadiusImageView in XML or code.
- Use scaleType for scaling behavior on this view.
- Give the view fixed or constrained dimensions so corner rounding works.
- Search layouts for adjustViewBounds when migrating plain ImageViews to QMUIRadiusImageView.
When it happens
Trigger: Calling setAdjustViewBounds(true) on a QMUIRadiusImageView, or inflating its XML with android:adjustViewBounds="true".
Common situations: Copying layout XML from a plain ImageView, or a designer-requested 'fit width' behavior applied to an avatar/border image that must stay circular.
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
- Use addContentView(View, ConstraintLayout.LayoutParams) for
- Use addContentView(int) for replacement
- Use addContentView(View, QMUIPriorityLinearLayout.LayoutPara
- Not support the type: %s
- topView must implement from IQMUIContinuousNestedTopView
AI-assisted analysis of Tencent/QMUI_Android@026e7d4866 (2026-09-06).
Data as JSON: /api/errors/4e2466163b65eccb.
Report an issue: GitHub.