{"record":{"id":"1702fdd481155af3","repo":"jfeinstein10/SlidingMenu","slug":"the-behindfadedegree-must-be-between-0-0f-and-1-0f","errorCode":null,"errorMessage":"The BehindFadeDegree must be between 0.0f and 1.0f","messagePattern":"The BehindFadeDegree must be between 0\\.0f and 1\\.0f","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"library/src/com/jeremyfeinstein/slidingmenu/lib/CustomViewBehind.java","lineNumber":200,"sourceCode":"\t}\n\n\tpublic void setSecondaryShadowDrawable(Drawable shadow) {\n\t\tmSecondaryShadowDrawable = shadow;\n\t\tinvalidate();\n\t}\n\n\tpublic void setShadowWidth(int width) {\n\t\tmShadowWidth = width;\n\t\tinvalidate();\n\t}\n\n\tpublic void setFadeEnabled(boolean b) {\n\t\tmFadeEnabled = b;\n\t}\n\n\tpublic void setFadeDegree(float degree) {\n\t\tif (degree > 1.0f || degree < 0.0f)\n\t\t\tthrow new IllegalStateException(\"The BehindFadeDegree must be between 0.0f and 1.0f\");\n\t\tmFadeDegree = degree;\n\t}\n\n\tpublic int getMenuPage(int page) {\n\t\tpage = (page > 1) ? 2 : ((page < 1) ? 0 : page);\n\t\tif (mMode == SlidingMenu.LEFT && page > 1) {\n\t\t\treturn 0;\n\t\t} else if (mMode == SlidingMenu.RIGHT && page < 1) {\n\t\t\treturn 2;\n\t\t} else {\n\t\t\treturn page;\n\t\t}\n\t}\n\n\tpublic void scrollBehindTo(View content, int x, int y) {\n\t\tint vis = View.VISIBLE;\t\t\n\t\tif (mMode == SlidingMenu.LEFT) {\n\t\t\tif (x >= content.getLeft()) vis = View.INVISIBLE;","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/jfeinstein10/SlidingMenu/blob/4254feca3ece9397cd501921ee733f19ea0fdad8/library/src/com/jeremyfeinstein/slidingmenu/lib/CustomViewBehind.java#L182-L218","documentation":"SlidingMenu's setFadeDegree() validates that the fade amount for the behind view lies in [0.0f, 1.0f]. 0 means no fade and 1 means full fade as the menu slides; anything else would produce undefined rendering, so the library throws IllegalStateException immediately.","triggerScenarios":"Calling CustomViewBehind.setFadeDegree(float) (usually via SlidingMenu.setBehindFadeDegree) with a negative value or a value greater than 1.0f.","commonSituations":"Passing a percentage like 50 instead of 0.5f; computing the degree from pixels or dpi values; typo'ing a scale factor (e.g. 1.5f intended as clamped fade).","solutions":["Pass a float clamped to [0.0f, 1.0f], e.g. Math.max(0f, Math.min(1f, value))","If using a percentage 0-100, divide by 100f before calling","Call inside a try-catch or validate before assigning"],"exampleFix":"// before\nslidingMenu.setBehindFadeDegree(1.2f);\n// after\nfloat fade = 1.2f;\nslidingMenu.setBehindFadeDegree(Math.max(0f, Math.min(1f, fade)));","handlingStrategy":"validation","validationCode":"if (degree < 0f || degree > 1f) throw new IllegalArgumentException(\"fade degree must be in [0,1]: \" + degree);\nslidingMenu.setBehindFadeDegree(degree);","typeGuard":"static boolean isValidFadeDegree(Float d) { return d != null && !d.isNaN() && d >= 0f && d <= 1f; }","tryCatchPattern":"try { slidingMenu.setBehindFadeDegree(degree); } catch (IllegalStateException e) { slidingMenu.setBehindFadeDegree(0f); }","preventionTips":["Always clamp with Math.max(0f, Math.min(1f, value))","Convert percentages to fractions (value / 100f)","Unit-test fade configuration values"],"tags":["android","slidingmenu","range-validation","illegal-argument"],"backgroundTag":"value-out-of-range","analyzedSha":"4254feca3ece9397cd501921ee733f19ea0fdad8","analyzedAt":"2026-09-09T10:08:27.041Z","contentChangedAt":"2026-09-09T10:08:27.041Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}