{"record":{"id":"07e9132ab488c44c","repo":"umano/AndroidSlidingUpPanel","slug":"height-must-have-an-exact-value-or-match-parent","errorCode":null,"errorMessage":"Height must have an exact value or MATCH_PARENT","messagePattern":"Height must have an exact value or MATCH_PARENT","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java","lineNumber":734,"sourceCode":"    }\n\n    @Override\n    protected void onDetachedFromWindow() {\n        super.onDetachedFromWindow();\n        mFirstLayout = true;\n    }\n\n    @Override\n    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {\n        final int widthMode = MeasureSpec.getMode(widthMeasureSpec);\n        final int widthSize = MeasureSpec.getSize(widthMeasureSpec);\n        final int heightMode = MeasureSpec.getMode(heightMeasureSpec);\n        final int heightSize = MeasureSpec.getSize(heightMeasureSpec);\n\n        if (widthMode != MeasureSpec.EXACTLY && widthMode != MeasureSpec.AT_MOST) {\n            throw new IllegalStateException(\"Width must have an exact value or MATCH_PARENT\");\n        } else if (heightMode != MeasureSpec.EXACTLY && heightMode != MeasureSpec.AT_MOST) {\n            throw new IllegalStateException(\"Height must have an exact value or MATCH_PARENT\");\n        }\n\n        final int childCount = getChildCount();\n\n        if (childCount != 2) {\n            throw new IllegalStateException(\"Sliding up panel layout must have exactly 2 children!\");\n        }\n\n        mMainView = getChildAt(0);\n        mSlideableView = getChildAt(1);\n        if (mDragView == null) {\n            setDragView(mSlideableView);\n        }\n\n        // If the sliding panel is not visible, then put the whole view in the hidden state\n        if (mSlideableView.getVisibility() != VISIBLE) {\n            mSlideState = PanelState.HIDDEN;\n        }","sourceCodeStart":716,"sourceCodeEnd":752,"githubUrl":"https://github.com/umano/AndroidSlidingUpPanel/blob/45a460435b07e764138a700328836cafc1ed5c42/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java#L716-L752","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before\n<SlidingUpPanelLayout android:layout_height=\"wrap_content\" ... />\n// after\n<SlidingUpPanelLayout android:layout_height=\"match_parent\" ... />","handlingStrategy":"validation","validationCode":"ViewGroup.LayoutParams lp = layout.getLayoutParams();\nif (lp != null && lp.height == ViewGroup.LayoutParams.WRAP_CONTENT) lp.height = ViewGroup.LayoutParams.MATCH_PARENT;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use match_parent or fixed height on the root","Apply wrap_content only to the panel child where supported","Avoid ScrollView as direct parent"],"tags":["android","layout","measure-spec"],"backgroundTag":"invalid-config-value","analyzedSha":"45a460435b07e764138a700328836cafc1ed5c42","analyzedAt":"2026-09-11T10:02:33.403Z","contentChangedAt":"2026-09-11T10:02:33.403Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}