umano/AndroidSlidingUpPanel · error · java.lang.IllegalStateException
Height must have an exact value or MATCH_PARENT
Error message
Height must have an exact value or MATCH_PARENT
What it means
Same onMeasure validation as width, applied to height: the height measure spec must be EXACTLY or AT_MOST. The layout computes panel slide ranges from a concrete height, so UNSPECIFIED height is rejected.
Solutions
- Set layout_height to match_parent or a fixed dp value on SlidingUpPanelLayout
- Keep wrap_content on the inner panel child only if supported, never on the root
- Ensure the parent provides bounded height (avoid raw ScrollView wrapping)
Example fix
// before <SlidingUpPanelLayout android:layout_height="wrap_content" ... /> // after <SlidingUpPanelLayout android:layout_height="match_parent" ... />
Defensive patterns
Strategy: validation
Validate before calling
ViewGroup.LayoutParams lp = layout.getLayoutParams(); if (lp != null && lp.height == ViewGroup.LayoutParams.WRAP_CONTENT) lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
Prevention
- Use match_parent or fixed height on the root
- Apply wrap_content only to the panel child where supported
- Avoid ScrollView as direct parent
When it happens
Trigger: SlidingUpPanelLayout declared with layout_height="wrap_content" in a parent that measures with UNSPECIFIED height, or placed directly inside ScrollView/CoordinatorLayout setups that pass unbounded height.
Common situations: Developers try to make the panel height depend on its content by using wrap_content on the root layout instead of on the panel child.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Width must have an exact value or MATCH_PARENT
- Sliding up panel layout must have exactly 2 children!
- gravity must be set to either top or bottom
- Panel state cannot be null or DRAGGING.
- Parent view may not be null
AI-assisted analysis of umano/AndroidSlidingUpPanel@45a460435b (2026-09-11).
Data as JSON: /api/errors/07e9132ab488c44c.
Report an issue: GitHub.
Appendix: source
Thrown at library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java:734
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
mFirstLayout = true;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
final int heightSize = MeasureSpec.getSize(heightMeasureSpec);
if (widthMode != MeasureSpec.EXACTLY && widthMode != MeasureSpec.AT_MOST) {
throw new IllegalStateException("Width must have an exact value or MATCH_PARENT");
} else if (heightMode != MeasureSpec.EXACTLY && heightMode != MeasureSpec.AT_MOST) {
throw new IllegalStateException("Height must have an exact value or MATCH_PARENT");
}
final int childCount = getChildCount();
if (childCount != 2) {
throw new IllegalStateException("Sliding up panel layout must have exactly 2 children!");
}
mMainView = getChildAt(0);
mSlideableView = getChildAt(1);
if (mDragView == null) {
setDragView(mSlideableView);
}
// If the sliding panel is not visible, then put the whole view in the hidden state
if (mSlideableView.getVisibility() != VISIBLE) {
mSlideState = PanelState.HIDDEN;
}View on GitHub (pinned to 45a460435b)