{"record":{"id":"1fb4c66991c516cf","repo":"gyf-dev/ImmersionBar","slug":"view","errorCode":null,"errorMessage":"View参数不能为空","messagePattern":"View参数不能为空","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"immersionbar/src/main/java/com/gyf/immersionbar/ImmersionBar.java","lineNumber":3762,"sourceCode":"     * @return the immersion bar\n     */\n    public ImmersionBar addViewSupportTransformColor(View view, String viewColorBeforeTransform,\n                                                     String viewColorAfterTransform) {\n        return this.addViewSupportTransformColorInt(view,\n                Color.parseColor(viewColorBeforeTransform),\n                Color.parseColor(viewColorAfterTransform));\n    }\n\n    /**\n     * Add 颜色变换支持View\n     *\n     * @param view                    the view\n     * @param viewColorAfterTransform the view color after transform\n     * @return the immersion bar\n     */\n    public ImmersionBar addViewSupportTransformColorInt(View view, @ColorInt int viewColorAfterTransform) {\n        if (view == null) {\n            throw new IllegalArgumentException(\"View参数不能为空\");\n        }\n        Map<Integer, Integer> map = new HashMap<>();\n        map.put(mBarParams.statusBarColor, viewColorAfterTransform);\n        mBarParams.viewMap.put(view, map);\n        return this;\n    }\n\n    /**\n     * Add 颜色变换支持View\n     *\n     * @param view                     the view\n     * @param viewColorBeforeTransform the view color before transform\n     * @param viewColorAfterTransform  the view color after transform\n     * @return the immersion bar\n     */\n    public ImmersionBar addViewSupportTransformColorInt(View view, @ColorInt int viewColorBeforeTransform,\n                                                        @ColorInt int viewColorAfterTransform) {\n        if (view == null) {","sourceCodeStart":3744,"sourceCodeEnd":3780,"githubUrl":"https://github.com/gyf-dev/ImmersionBar/blob/8cac10cd83d809eac54f42b37f92340c4a25c4ac/immersionbar/src/main/java/com/gyf/immersionbar/ImmersionBar.java#L3744-L3780","documentation":"addViewSupportTransformColorInt registers a View whose color should transform along with the status bar. It validates that the view is non-null and throws IllegalArgumentException(\"View参数不能为空\") (\"view parameter cannot be empty\") otherwise, since a null view cannot be keyed into the internal viewMap.","triggerScenarios":"Calling addViewSupportTransformColorInt(null, someColor), often when the view reference comes from findViewById that returned null or a lazily-inflated field still null.","commonSituations":"View not yet inflated when the bar is configured; wrong layout id causing findViewById to return null; Kotlin lateinit/Jetpack binding accessed too early.","solutions":["Pass a valid, already-inflated View reference (ensure findViewById/bindings ran first)","Null-check the view before configuring the bar","Move the call after setContentView/onViewCreated"],"exampleFix":"// before\nbar.addViewSupportTransformColorInt(toolbar, Color.TRANSPARENT); // toolbar null\n// after\nView toolbar = findViewById(R.id.toolbar);\nif (toolbar != null) {\n    bar.addViewSupportTransformColorInt(toolbar, Color.TRANSPARENT);\n}","handlingStrategy":"validation","validationCode":"if (view != null) { bar.addViewSupportTransformColorInt(view, color); }","typeGuard":"View requireView(View v) { if (v == null) throw new IllegalStateException(\"view not inflated\"); return v; }","tryCatchPattern":"try { bar.addViewSupportTransformColorInt(view, color); } catch (IllegalArgumentException e) { Log.e(TAG, \"null view for transform color\", e); }","preventionTips":["Call only after setContentView/onViewCreated","Never rely on findViewById without a null check","Use ViewBinding to eliminate null views"],"tags":["android","null-check","view","argument-validation"],"backgroundTag":"null-argument","analyzedSha":"8cac10cd83d809eac54f42b37f92340c4a25c4ac","analyzedAt":"2026-09-08T11:52:01.757Z","contentChangedAt":"2026-09-08T11:52:01.757Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}