material-components/material-components-android · error · IllegalArgumentException
Invalid view edge position value:
Error message
Invalid view edge position value:
What it means
HideViewOnScrollBehavior selects an internal delegate (HideRightViewOnScrollDelegate, HideBottomViewOnScrollDelegate, or HideLeftViewOnScrollDelegate) from the view edge attribute. Only EDGE_RIGHT, EDGE_BOTTOM, and EDGE_LEFT are valid; any other value falls through the switch and throws IllegalArgumentException naming the accepted constants.
Source
Thrown at lib/java/com/google/android/material/behavior/HideViewOnScrollBehavior.java:192
public void setViewEdge(@ViewEdge int viewEdge) {
viewEdgeOverride = true;
setViewEdgeInternal(viewEdge);
}
private void setViewEdgeInternal(@ViewEdge int viewEdge) {
if (hideOnScrollViewDelegate == null || hideOnScrollViewDelegate.getViewEdge() != viewEdge) {
switch (viewEdge) {
case EDGE_RIGHT:
this.hideOnScrollViewDelegate = new HideRightViewOnScrollDelegate();
break;
case EDGE_BOTTOM:
this.hideOnScrollViewDelegate = new HideBottomViewOnScrollDelegate();
break;
case EDGE_LEFT:
this.hideOnScrollViewDelegate = new HideLeftViewOnScrollDelegate();
break;
default:
throw new IllegalArgumentException(
"Invalid view edge position value: "
+ viewEdge
+ ". Must be "
+ EDGE_RIGHT
+ ", "
+ EDGE_BOTTOM
+ " or "
+ EDGE_LEFT
+ ".");
}
}
}
private boolean isGravityBottom(int viewGravity) {
return viewGravity == Gravity.BOTTOM || (viewGravity == (Gravity.BOTTOM | Gravity.CENTER));
}
private boolean isGravityLeft(int viewGravity) {View on GitHub (pinned to ac7e18efee)
Solutions
- Set the edge attribute to one of the documented constants: EDGE_RIGHT, EDGE_BOTTOM, or EDGE_LEFT.
- If set in code, reference the class constants (e.g. HideViewOnScrollBehavior.EDGE_BOTTOM) instead of raw ints.
- After upgrading Material Components, re-check the edge attribute values for renames and update the XML.
Example fix
<!-- before --> <item name="behavior_hideOnScrollViewEdge">3</item> <!-- invalid raw value --> <!-- after --> <item name="behavior_hideOnScrollViewEdge">bottom</item> <!-- valid edge -->
Defensive patterns
Strategy: validation
Validate before calling
int edge = HideViewOnScrollBehavior.EDGE_BOTTOM; // one of EDGE_RIGHT/EDGE_BOTTOM/EDGE_LEFT only
boolean valid = edge == HideViewOnScrollBehavior.EDGE_RIGHT
|| edge == HideViewOnScrollBehavior.EDGE_BOTTOM
|| edge == HideViewOnScrollBehavior.EDGE_LEFT; Prevention
- Reference class constants instead of raw ints in XML or code.
- Re-verify edge attribute values after every Material Components upgrade.
When it happens
Trigger: Constructing HideViewOnScrollBehavior(context, attrs) where the XML behavior attribute for the edge is set to an unrecognized/unset value; or calling the internal edge-setting path programmatically with a constant other than EDGE_RIGHT/EDGE_BOTTOM/EDGE_LEFT.
Common situations: Hand-editing the behavior XML attributes and typos or removes the edge value; library version change that introduced/renamed edge constants while the app still passes an old custom int; programmatically passing 0 or an arbitrary int because the constant was not imported.
Related errors
- AppBarLayout is always vertical and does not support horizon
- The view is not a child of CoordinatorLayout
- The view is not associated with HideViewOnScrollBehavior
- iconGravity cannot have the same alignment as secondaryIconG
- Email %d does not exist.
AI-assisted analysis of material-components/material-components-android@ac7e18efee (2026-08-14).
Data as JSON: /api/errors/b733a79d96a7cf78.
Report an issue: GitHub.