umano/AndroidSlidingUpPanel · error · java.lang.IllegalArgumentException
captureChildView: parameter must be a descendant of the…
Error message
captureChildView: parameter must be a descendant of the ViewDragHelper's tracked parent view (mParentView)
What it means
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.
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
Example fix
// before mDragHelper = ViewDragHelper.create((ViewGroup) getParent(), 1f, cb); // wrong parent // after mDragHelper = ViewDragHelper.create(this, 1f, cb); // direct parent of dragged children
Defensive patterns
Strategy: validation
Validate before calling
@Override
public boolean tryCaptureView(View child, int pointerId) {
return child.getParent() == this; // only direct children of mParentView
} Type guard
boolean isDirectChild(View v, ViewGroup p) { return v.getParent() == p; } Try / catch
try { mDragHelper.captureChildView(v, pointerId); } catch (IllegalArgumentException e) { Log.w(TAG, "view not child of tracked parent", e); } Prevention
- Create helper with the direct parent of draggable children
- Gate tryCaptureView with a parent check
- Watch for view re-parenting (RecyclerView recycling)
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Parent view may not be null
- Callback may not be null
- Cannot settleCapturedViewAt outside of a call to…
- Cannot flingCapturedView outside of a call to…
- gravity must be set to either top or bottom
AI-assisted analysis of umano/AndroidSlidingUpPanel@45a460435b (2026-09-11).
Data as JSON: /api/errors/9d325e42cceeafba.
Report an issue: GitHub.
Appendix: source
Thrown at library/src/main/java/com/sothree/slidinguppanel/ViewDragHelper.java:492
*
* @return The size of an edge in pixels
* @see #setEdgeTrackingEnabled(int)
*/
public int getEdgeSize() {
return mEdgeSize;
}
/**
* Capture a specific child view for dragging within the parent. The callback will be notified
* but {@link Callback#tryCaptureView(android.view.View, int)} will not be asked permission to
* capture this view.
*
* @param childView Child view to capture
* @param activePointerId ID of the pointer that is dragging the captured child view
*/
public void captureChildView(View childView, int activePointerId) {
if (childView.getParent() != mParentView) {
throw new IllegalArgumentException("captureChildView: parameter must be a descendant " +
"of the ViewDragHelper's tracked parent view (" + mParentView + ")");
}
mCapturedView = childView;
mActivePointerId = activePointerId;
mCallback.onViewCaptured(childView, activePointerId);
setDragState(STATE_DRAGGING);
}
/**
* @return The currently captured view, or null if no view has been captured.
*/
public View getCapturedView() {
return mCapturedView;
}
/**
* @return The ID of the pointer currently dragging the captured view,View on GitHub (pinned to 45a460435b)