{"record":{"id":"b16f30bde9a3a6d4","repo":"Tencent/QMUI_Android","slug":"more-than-one-view-in-xml-are-marked-by-qmui-is-ta","errorCode":null,"errorMessage":"More than one view in xml are marked by qmui_is_target = true.","messagePattern":"More than one view in xml are marked by qmui_is_target = true\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"qmui/src/main/java/com/qmuiteam/qmui/widget/pullLayout/QMUIPullLayout.java","lineNumber":120,"sourceCode":"        TypedArray array = context.obtainStyledAttributes(attrs,\n                R.styleable.QMUIPullLayout, defStyleAttr, 0);\n        mEnabledEdges = array.getInt(R.styleable.QMUIPullLayout_qmui_pull_enable_edge, PUL_EDGE_ALL);\n        array.recycle();\n        mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);\n        mScroller = new OverScroller(context, QUNITIC_INTERPOLATOR);\n    }\n\n    @Override\n    protected void onFinishInflate() {\n        super.onFinishInflate();\n        boolean isTargetSet = false;\n        int edgesSet = 0;\n        for (int i = 0; i < getChildCount(); i++) {\n            View view = getChildAt(i);\n            LayoutParams lp = (LayoutParams) view.getLayoutParams();\n            if (lp.isTarget) {\n                if (isTargetSet) {\n                    throw new RuntimeException(\n                            \"More than one view in xml are marked by qmui_is_target = true.\");\n                }\n                isTargetSet = true;\n                setTargetView(view);\n            } else {\n                if ((edgesSet & lp.edge) != 0) {\n                    String text = \"\";\n                    if (lp.edge == PULL_EDGE_LEFT) {\n                        text = \"left\";\n                    } else if (lp.edge == PULL_EDGE_TOP) {\n                        text = \"top\";\n                    } else if (lp.edge == PULL_EDGE_RIGHT) {\n                        text = \"right\";\n                    } else if (lp.edge == PULL_EDGE_BOTTOM) {\n                        text = \"bottom\";\n                    }\n                    throw new RuntimeException(\"More than one view in xml marked by qmui_layout_edge = \" + text);\n                }","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/Tencent/QMUI_Android/blob/026e7d486677d6593a96689cd590ec3561176717/qmui/src/main/java/com/qmuiteam/qmui/widget/pullLayout/QMUIPullLayout.java#L102-L138","documentation":"QMUIPullLayout.onFinishInflate throws when more than one child view in the layout XML has qmui_is_target=\"true\". The pull layout supports exactly one target view (the scrollable content), so duplicates are treated as an invalid layout.","triggerScenarios":"Declaring two or more children in the QMUIPullLayout XML with the attribute app:qmui_is_target=\"true\"; also merging/inflating an included layout that also marks a target into the same pull layout.","commonSituations":"Copy-pasting a child block in XML and leaving the attribute on both; combining a manually declared target with an <include> whose root also sets qmui_is_target.","solutions":["Keep qmui_is_target=\"true\" on exactly one direct child of QMUIPullLayout.","Remove the attribute from included/merged layouts, or set it only on the include root.","Move non-target content (e.g. action views) to children marked only with qmui_layout_edge."],"exampleFix":"<!-- before -->\n<com.qmuiteam.qmui.widget.pullLayout.QMUIPullLayout>\n    <View app:layout_qmui_is_target=\"true\"/>\n    <View app:layout_qmui_is_target=\"true\"/>\n</...>\n<!-- after: only one target -->\n<com.qmuiteam.qmui.widget.pullLayout.QMUIPullLayout>\n    <View app:layout_qmui_is_target=\"true\"/>\n    <View app:layout_qmui_layout_edge=\"top\"/>\n</...>","handlingStrategy":"validation","validationCode":"// pre-inflate XML audit\nint targetCount = 0;\nfor (int i = 0; i < pullLayout.getChildCount(); i++) {\n    QMUIPullLayout.LayoutParams lp = (QMUIPullLayout.LayoutParams) pullLayout.getChildAt(i).getLayoutParams();\n    if (lp.isTarget) targetCount++;\n}\n// targetCount must be exactly 1","typeGuard":null,"tryCatchPattern":"try {\n    setContentView(R.layout.pull_screen);\n} catch (RuntimeException e) {\n    throw new IllegalStateException(\"check qmui_is_target: exactly one child allowed\", e);\n}","preventionTips":["Mark qmui_is_target on exactly one direct child per QMUIPullLayout.","Never mark targets inside <include>/<merge> sources that get inflated into the pull layout.","Lint/review XML diffs for duplicated attributes after copy-paste."],"tags":["android","qmui","layout-inflation","xml"],"backgroundTag":"invalid-config-value","analyzedSha":"026e7d486677d6593a96689cd590ec3561176717","analyzedAt":"2026-09-06T13:32:24.816Z","contentChangedAt":"2026-09-06T13:32:24.816Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}