{"record":{"id":"1610317ab57e6458","repo":"material-components/material-components-android","slug":"the-view-is-not-a-child-of-coordinatorlayout-161031","errorCode":null,"errorMessage":"The view is not a child of CoordinatorLayout","messagePattern":"The view is not a child of CoordinatorLayout","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/sidesheet/SideSheetBehavior.java","lineNumber":1169,"sourceCode":"          @Override\n          public SavedState[] newArray(int size) {\n            return new SavedState[size];\n          }\n        };\n  }\n\n  /**\n   * A utility function to get the {@link SideSheetBehavior} associated with the {@code view}.\n   *\n   * @param view The {@link View} with {@link SideSheetBehavior}.\n   * @return The {@link SideSheetBehavior} associated with the {@code view}.\n   */\n  @NonNull\n  @SuppressWarnings(\"unchecked\")\n  public static <V extends View> SideSheetBehavior<V> from(@NonNull V view) {\n    ViewGroup.LayoutParams params = view.getLayoutParams();\n    if (!(params instanceof LayoutParams)) {\n      throw new IllegalArgumentException(\"The view is not a child of CoordinatorLayout\");\n    }\n    CoordinatorLayout.Behavior<?> behavior = ((LayoutParams) params).getBehavior();\n    if (!(behavior instanceof SideSheetBehavior)) {\n      throw new IllegalArgumentException(\"The view is not associated with SideSheetBehavior\");\n    }\n    return (SideSheetBehavior<V>) behavior;\n  }\n\n  private void updateAccessibilityActions() {\n    if (viewRef == null) {\n      return;\n    }\n    V child = viewRef.get();\n    if (child == null) {\n      return;\n    }\n    ViewCompat.removeAccessibilityAction(child, AccessibilityNodeInfoCompat.ACTION_EXPAND);\n    ViewCompat.removeAccessibilityAction(child, AccessibilityNodeInfoCompat.ACTION_DISMISS);","sourceCodeStart":1151,"sourceCodeEnd":1187,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/sidesheet/SideSheetBehavior.java#L1151-L1187","documentation":"SideSheetBehavior.from(view) throws IllegalArgumentException when the view's LayoutParams are not CoordinatorLayout.LayoutParams — i.e. the view is not a direct child of a CoordinatorLayout. from() reads the behavior off the child's layout params, so a view inflated elsewhere (LinearLayout, FragmentContainer, Dialog) fails this check before behavior lookup.","triggerScenarios":"Calling SideSheetBehavior.from(findViewById(R.id.sheet)) when the sheet view is nested inside another container (e.g. a LinearLayout inside CoordinatorLayout, or placed in a ConstraintLayout) instead of being a direct child of CoordinatorLayout.","commonSituations":"Wrapping the sheet in an extra container 'for spacing'; moving layouts during refactors so the sheet is no longer a direct CoordinatorLayout child; dialog content where the root is not a CoordinatorLayout.","solutions":["Move the sheet view so it is a direct child of the CoordinatorLayout.","Apply app:layout_behavior=\"com.google.android.material.sidesheet.SideSheetBehavior\" on that direct child.","If you only have a nested reference, resolve the CoordinatorLayout child first (e.g. (CoordinatorLayout) view.getParent().getParent()) and call from() on the right view."],"exampleFix":"<!-- before -->\n<CoordinatorLayout ...>\n    <LinearLayout ...>\n        <View android:id=\"@+id/sheet\" />\n    </LinearLayout>\n</CoordinatorLayout>\n\n<!-- after -->\n<CoordinatorLayout ...>\n    <LinearLayout android:id=\"@+id/sheet\"\n        app:layout_behavior=\"com.google.android.material.sidesheet.SideSheetBehavior\" />\n</CoordinatorLayout>","handlingStrategy":"type-guard","validationCode":"View directChild = sheetView;\nViewParent p = sheetView.getParent();\nif (p instanceof CoordinatorLayout) {\n  SideSheetBehavior<View> b = SideSheetBehavior.from(sheetView);\n} else {\n  throw new IllegalStateException(\"Sheet must be a direct child of CoordinatorLayout\");\n}","typeGuard":"static boolean isCoordinatorLayoutChild(View v) {\n  return v.getLayoutParams() instanceof CoordinatorLayout.LayoutParams;\n}","tryCatchPattern":null,"preventionTips":["Keep the sheet as a direct child of CoordinatorLayout in the layout file.","Check view.getLayoutParams() instanceof CoordinatorLayout.LayoutParams before from()."],"tags":["android","material-components","sidesheet","layout","coordinatorlayout"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}