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

[NavigationView] Add support for expandable items

Open
#1,759 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

**Problem description**
Android's implementation for Material Components should support having expandable items in the `NavigationView`, such as those depicted in the Fortnightly material app design sample and also showcased in the [Navigation Drawer page](https://material.io/components/navigation-drawer#theming).

**Alternatives**
Alternatives to implement this vary from using `ExpandableListView` and loosing the ability to declare the items using a simple hierarchical menu XML file to declaring a menu item with a custom `actionLayout` that triggers visibility of a group of other items declared below (and with no way of animating the transition). These are cumbersome and require quite a bit of effort to get them working right.

**Additional context**
There're quite a few StackOverflow posts and GitHub open source project that attempt to provide a solution for this problem, but none providing a clean solution that goes with the XML declarative approach. Code samples may be provided if required.

**Edit:** Actually, one of the most popular open source projects ([MaterialDrawer](https://github.com/mikepenz/MaterialDrawer)) supports this. Still, I'd rather not have to use another third party library just for a common use case (as showcased in the Material Design site).

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 by reviewing the NavigationView component and its menu XML handling. Compare the requested behavior with the Material Design Navigation Drawer example and the mentioned ExpandableListView and actionLayout alternatives. Done means NavigationView supports expandable hierarchical items through a clean XML-declarative approach, with behavior suitable for the showcased use case.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.