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

[AppBarLayout] Enhance setExpanded() to support 'collapsed with minHeight' state

Open
#1,922 1 comment 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

When 'minHeight' is set and scrollFlags includes 'enterAlwaysCollapsed',
scroll up shows only minHeight. ('Collapsed' state)

and setExpanded(true) shows full height. ('Expanded' state)

but setExpanded(false) hide appbar completely.('Hidden' state)
so I can't go back to 'Collapsed' state programmatically.

I suggest to support these Hidden/Collapsed/Expanded state.

I tested by modifying BaseBehavior.onLayoutChild(),
- adding PENDING_ACTION_EXPAND_MIN_HEIGHT,
- offset=abl.getDownNestedPreScrollRange() - abl.getUpNestedPreScrollRange()
will do.

I know the name is confusing. but PENDING_ACTION_COLLAPSED is already used for hidden state. :(

If owner agrees this feature and decide interface, I will upload 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

Start with BaseBehavior.onLayoutChild() and the existing AppBarLayout.setExpanded() behavior described in the issue. Trace how enterAlwaysCollapsed, minHeight, and the pending action states represent hidden and expanded modes. The interface for a collapsed-with-minHeight state still needs owner agreement; done means all three states can be selected programmatically without breaking existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
mobile
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.