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

[AppBarLayout ] AppBarLayout does not support fling dispatch feature when sliding down

Open
#2,297 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request Widget: TopAppBar
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

**Description:** When AppBarLayout slides downwards, HeaderBehavior limits the maximum sliding distance, consumes all the sliding speed, is not distributed, and does not support nested sliding

**Expected behavior:** AppBarLayout support fling dispatch feature when sliding down

**Android API version:** 30

**Material Library version:** 1.5.0-alpha01

**Code In HeaderBehavior:**

```
final boolean fling(
CoordinatorLayout coordinatorLayout,
@NonNull V layout,
int minOffset,
int maxOffset,
float velocityY) {
if (flingRunnable != null) {
layout.removeCallbacks(flingRunnable);
flingRunnable = null;
}

if (scroller == null) {
scroller = new OverScroller(layout.getContext());
}

scroller.fling(
0,
getTopAndBottomOffset(), // curr
0,
Math.round(velocityY), // velocity.
0,
0, // x
minOffset,
maxOffset); // y

if (scroller.computeScrollOffset()) {
flingRunnable = new FlingRunnable(coordinatorLayout, layout);
ViewCompat.postOnAnimation(layout, flingRunnable);
return true;
} else {
onFlingFinished(coordinatorLayout, layout);
return false;
}
}
```

```
private class FlingRunnable implements Runnable {
private final CoordinatorLayout parent;
private final V layout;

FlingRunnable(CoordinatorLayout parent, V layout) {
this.parent = parent;
this.layout = layout;
}

@Override
public void run() {
if (layout != null && scroller != null) {
if (scroller.computeScrollOffset()) {
setHeaderTopBottomOffset(parent, layout, scroller.getCurrY());
// Post ourselves so that we run on the next animation
ViewCompat.postOnAnimation(layout, this);
} else {
onFlingFinished(parent, layout);
}
}
}
}
```

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

Start with the HeaderBehavior.fling implementation and FlingRunnable shown in the report, using the Android API 30 and Material Library 1.5.0-alpha01 context. Reproduce AppBarLayout sliding downward and verify that fling velocity is dispatched rather than consumed, with nested sliding supported and the expected maximum distance preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.