{"record":{"id":"e97eb33520a12c66","repo":"material-components/material-components-android","slug":"the-view-is-not-associated-with-bottomsheetbehavio","errorCode":null,"errorMessage":"The view is not associated with BottomSheetBehavior","messagePattern":"The view is not associated with BottomSheetBehavior","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/bottomsheet/BottomSheetBehavior.java","lineNumber":2472,"sourceCode":"  }\n\n  /**\n   * A utility function to get the {@link BottomSheetBehavior} associated with the {@code view}.\n   *\n   * @param view The {@link View} with {@link BottomSheetBehavior}.\n   * @return The {@link BottomSheetBehavior} associated with the {@code view}.\n   */\n  @NonNull\n  @SuppressWarnings(\"unchecked\")\n  public static <V extends View> BottomSheetBehavior<V> from(@NonNull V view) {\n    ViewGroup.LayoutParams params = view.getLayoutParams();\n    if (!(params instanceof CoordinatorLayout.LayoutParams)) {\n      throw new IllegalArgumentException(\"The view is not a child of CoordinatorLayout\");\n    }\n    CoordinatorLayout.Behavior<?> behavior =\n        ((CoordinatorLayout.LayoutParams) params).getBehavior();\n    if (!(behavior instanceof BottomSheetBehavior)) {\n      throw new IllegalArgumentException(\"The view is not associated with BottomSheetBehavior\");\n    }\n    return (BottomSheetBehavior<V>) behavior;\n  }\n\n  /**\n   * Sets whether the BottomSheet should update the accessibility status of its {@link\n   * CoordinatorLayout} siblings when expanded.\n   *\n   * <p>Set this to true if the expanded state of the sheet blocks access to siblings (e.g., when\n   * the sheet expands over the full screen).\n   */\n  public void setUpdateImportantForAccessibilityOnSiblings(\n      boolean updateImportantForAccessibilityOnSiblings) {\n    this.updateImportantForAccessibilityOnSiblings = updateImportantForAccessibilityOnSiblings;\n  }\n\n  private void updateImportantForAccessibility(boolean expanded) {\n    if (viewRef == null) {","sourceCodeStart":2454,"sourceCodeEnd":2490,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/bottomsheet/BottomSheetBehavior.java#L2454-L2490","documentation":"BottomSheetBehavior.from(View) checks, after confirming CoordinatorLayout.LayoutParams, that the attached behavior is actually a BottomSheetBehavior. If app:layout_behavior is missing or set to another behavior class, the cast is impossible and IllegalArgumentException is thrown with this message.","triggerScenarios":"Calling BottomSheetBehavior.from(view) on a CoordinatorLayout child whose app:layout_behavior attribute is absent, misspelled, or points at a different behavior (AppBarLayout.Behavior, HideViewOnScrollBehavior, a custom Behavior).","commonSituations":"The behavior attribute was lost when moving/refactoring layout XML; a typo in the fully-qualified behavior class name in XML; calling the wrong from() (e.g. BottomSheetBehavior.from on a view carrying Snackbar.Behavior).","solutions":["Add app:layout_behavior=\"com.google.android.material.bottomsheet.BottomSheetBehavior\" to the sheet view.","Verify the class string has no typos and the xmlns:app namespace is declared on the root.","Confirm you are calling from() on the exact view that carries the BottomSheetBehavior, not a sibling or parent."],"exampleFix":"<!-- before -->\n<LinearLayout\n    android:id=\"+id/bottom_sheet\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\" /> <!-- no behavior -->\n\n<!-- after -->\n<LinearLayout\n    android:id=\"+id/bottom_sheet\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\"\n    app:layout_behavior=\"com.google.android.material.bottomsheet.BottomSheetBehavior\" />","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"private static boolean hasBottomSheetBehavior(View v) {\n  return v.getLayoutParams() instanceof CoordinatorLayout.LayoutParams\n      && ((CoordinatorLayout.LayoutParams) v.getLayoutParams()).getBehavior()\n          instanceof BottomSheetBehavior;\n}","tryCatchPattern":null,"preventionTips":["Always declare app:layout_behavior on the sheet view.","Check behavior XML strings for typos; unresolved classes leave the behavior unset."],"tags":["bottomsheet","coordinatorlayout","illegal-argument","configuration"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}