material-components / material-components/material-components-android

[AppBarLayout] Inconsistent default scrollFlags between XML and code

Open Beginner friendly
#5,082 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

**Description:**
`AppBarLayout.LayoutParams` defaults `scrollFlags` to `SCROLL_FLAG_SCROLL` (1) at field declaration, but XML inflation defaults to `0` (no scroll) when attribute is absent.

**Expected behavior:**
Both should default to `0` for consistency.

**Source code:**
```java
// Field declaration - defaults to 1
int scrollFlags = SCROLL_FLAG_SCROLL;
```

```java
// XML inflation - defaults to 0 when attribute missing
scrollFlags = a.getInt(R.styleable.AppBarLayout_Layout_layout_scrollFlags, 0);
```

**Workaround:**
Explicitly set `params.scrollFlags = 0` when creating programmatically.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate AppBarLayout.LayoutParams and compare the field declaration with the XML inflation path that reads layout_scrollFlags. Change the programmatic default to match the documented XML default of 0, then verify that both programmatic and XML-created parameters have no scroll flags when none are specified.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.