{"record":{"id":"f7cb4604fbf93014","repo":"material-components/material-components-android","slug":"the-view-is-not-associated-with-hideviewonscrollbe","errorCode":null,"errorMessage":"The view is not associated with HideViewOnScrollBehavior","messagePattern":"The view is not associated with HideViewOnScrollBehavior","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/behavior/HideViewOnScrollBehavior.java","lineNumber":511,"sourceCode":"  }\n\n  /**\n   * A utility function to get the {@link HideViewOnScrollBehavior} associated with the {@code\n   * view}.\n   *\n   * @param view The {@link View} with {@link HideViewOnScrollBehavior}.\n   * @return The {@link HideViewOnScrollBehavior} associated with the {@code view}.\n   */\n  @NonNull\n  @SuppressWarnings(\"unchecked\")\n  public static <V extends View> HideViewOnScrollBehavior<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 HideViewOnScrollBehavior)) {\n      throw new IllegalArgumentException(\n          \"The view is not associated with HideViewOnScrollBehavior\");\n    }\n    return (HideViewOnScrollBehavior<V>) behavior;\n  }\n}\n","sourceCodeStart":493,"sourceCodeEnd":517,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/behavior/HideViewOnScrollBehavior.java#L493-L517","documentation":"HideViewOnScrollBehavior.from(View) first verifies the view is a CoordinatorLayout child, then checks that the LayoutParams' behavior is a HideViewOnScrollBehavior. If a different behavior (or none) is attached, the cast is impossible and IllegalArgumentException is thrown with this message.","triggerScenarios":"Calling HideViewOnScrollBehavior.from(view) on a CoordinatorLayout child whose app:layout_behavior is missing, or set to another behavior such as AppBarLayout.Behavior, BottomSheetBehavior, or FloatingActionButton.Behavior.","commonSituations":"Copying a CoordinatorLayout child (e.g. a FAB) whose behavior attribute got dropped in the copy; using BottomSheetBehavior.from or other from() by mistake on the wrong view; behavior XML attribute typo so the class fails to resolve and no behavior is attached.","solutions":["Set app:layout_behavior=\"com.google.android.material.behavior.HideViewOnScrollBehavior\" on the view.","Confirm you are calling HideViewOnScrollBehavior.from on the view that actually carries this behavior (not another CoordinatorLayout child).","Check for typos in the behavior class string in XML — a bad class name silently leaves the behavior unset."],"exampleFix":"<!-- before -->\n<View\n    android:id=\"+id/hidable\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\" /> <!-- no behavior -->\n\n<!-- after -->\n<View\n    android:id=\"+id/hidable\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\"\n    app:layout_behavior=\"com.google.android.material.behavior.HideViewOnScrollBehavior\" />","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"private static boolean hasHideOnScrollBehavior(View v) {\n  return v.getLayoutParams() instanceof CoordinatorLayout.LayoutParams\n      && ((CoordinatorLayout.LayoutParams) v.getLayoutParams()).getBehavior()\n          instanceof HideViewOnScrollBehavior;\n}","tryCatchPattern":null,"preventionTips":["Set app:layout_behavior explicitly on every view you later query with from().","Double-check the behavior class string for typos in XML."],"tags":["behavior","coordinatorlayout","illegal-argument","configuration"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}