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

[AppBarLayout] Add setEnterAnchor/setExitAnchor with indirect child

Open
#1,934 0 comments 0 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

**Problem**
- layout_scrollFlags has to be set sequentially consistent among children
If button1..5 is vertically layout and I want to show button2(=enterAlways)
I have to set button2..5, same for exit
- collapse with minHeight works well but it requires additional height calculation for user.
If hierarchy is appbarlayout - constraintlayoutA - button1..5, then
I have to calculate set A's minHeight by summing button2..5

**Suggestion**
- Add setEnterAnchor(View) to AppBarLayout and let appbar calculate height
then when scroll down, appbarlayout scrolls down until anchor enter.
anchor view doesn't have to be a direct child.
anchor view needs to be set once so no more scroll|enterAlways cascades.
- setExpand(boolean) can be superseded. (#1922 won't be necessary then)
setExpand(true) -> setEnterAnchor(appbarlayout)
setExpand(false) -> setEnterAnchor(null)
- setExitAnthor(View) can be also set.
exit-anthor-view should be below enter-anchor-view, clearly.

**Alternative**
- Set tag to the anchor view in xml(or java) and let appbarlayout find it by full traverse.
I don't think using tag is appropriate but layout_flag can't be used for indirect child so I couldn't think other way.

**Compatibility**
- What if old(layout_scrollFlag) and new (anchor) behaviors conflict?

If you guys think this is an acceptable feature, I will happily make PR.

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

Review AppBarLayout's existing layout_scrollFlags, minHeight, and setExpand behavior first, then examine how indirect descendants are represented in the view hierarchy. Clarify the anchor API and its interaction with existing flags before implementation; done means the requested enter and exit behavior works without requiring sequential flags or manual minHeight calculations.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.