{"record":{"id":"9d325e42cceeafba","repo":"umano/AndroidSlidingUpPanel","slug":"capturechildview-parameter-must-be-a-descendant-o","errorCode":null,"errorMessage":"captureChildView: parameter must be a descendant of the ViewDragHelper's tracked parent view (mParentView)","messagePattern":"captureChildView: parameter must be a descendant of the ViewDragHelper's tracked parent view \\(mParentView\\)","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/sothree/slidinguppanel/ViewDragHelper.java","lineNumber":492,"sourceCode":"     *\n     * @return The size of an edge in pixels\n     * @see #setEdgeTrackingEnabled(int)\n     */\n    public int getEdgeSize() {\n        return mEdgeSize;\n    }\n\n    /**\n     * Capture a specific child view for dragging within the parent. The callback will be notified\n     * but {@link Callback#tryCaptureView(android.view.View, int)} will not be asked permission to\n     * capture this view.\n     *\n     * @param childView Child view to capture\n     * @param activePointerId ID of the pointer that is dragging the captured child view\n     */\n    public void captureChildView(View childView, int activePointerId) {\n        if (childView.getParent() != mParentView) {\n            throw new IllegalArgumentException(\"captureChildView: parameter must be a descendant \" +\n                    \"of the ViewDragHelper's tracked parent view (\" + mParentView + \")\");\n        }\n\n        mCapturedView = childView;\n        mActivePointerId = activePointerId;\n        mCallback.onViewCaptured(childView, activePointerId);\n        setDragState(STATE_DRAGGING);\n    }\n\n    /**\n     * @return The currently captured view, or null if no view has been captured.\n     */\n    public View getCapturedView() {\n        return mCapturedView;\n    }\n\n    /**\n     * @return The ID of the pointer currently dragging the captured view,","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/umano/AndroidSlidingUpPanel/blob/45a460435b07e764138a700328836cafc1ed5c42/library/src/main/java/com/sothree/slidinguppanel/ViewDragHelper.java#L474-L510","documentation":"captureChildView() requires the child's direct parent to be the mParentView the helper was created with; otherwise it throws IllegalArgumentException. This ensures drag coordinate math is done in the tracked parent's coordinate space.","triggerScenarios":"tryCaptureViewForDrag (via shouldCaptureView/callback) handing a view whose getParent() != mParentView — e.g. the Callback.tryCaptureView returns true for a child of a different container, or the helper was constructed with the wrong parent (getParent() instead of the view itself).","commonSituations":"Custom views where the drag helper is created with getParent() but the callback captures a nested child; view re-parenting at runtime (RecyclerView recycling) between helper creation and capture.","solutions":["Create the helper with the ViewGroup that directly contains the draggable children","In tryCaptureView, return true only for direct children of mParentView","Verify the captured view hasn't been re-parented before capture"],"exampleFix":"// before\nmDragHelper = ViewDragHelper.create((ViewGroup) getParent(), 1f, cb); // wrong parent\n// after\nmDragHelper = ViewDragHelper.create(this, 1f, cb); // direct parent of dragged children","handlingStrategy":"validation","validationCode":"@Override\npublic boolean tryCaptureView(View child, int pointerId) {\n    return child.getParent() == this; // only direct children of mParentView\n}","typeGuard":"boolean isDirectChild(View v, ViewGroup p) { return v.getParent() == p; }","tryCatchPattern":"try { mDragHelper.captureChildView(v, pointerId); } catch (IllegalArgumentException e) { Log.w(TAG, \"view not child of tracked parent\", e); }","preventionTips":["Create helper with the direct parent of draggable children","Gate tryCaptureView with a parent check","Watch for view re-parenting (RecyclerView recycling)"],"tags":["android","viewdraghelper","view-hierarchy"],"backgroundTag":"invalid-argument-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"}