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

[NavigationView] Attribute to se the ripple color on items

Open
#677 1 comment 4 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

The NavigationView uses a shaped background programmatically when itemShapeAppearance and/or itemShapeAppearanceOverlay is set.

However on the same item there is also a ripple when the item is clicked.

Schermata 2019-10-14 alle 14 35 28

In same cases it could be useful to have a selector with the same shape and without the grey ripple on background.

Schermata 2019-10-14 alle 11 47 14

Today I can achieve it using something like:

 <com.google.android.material.navigation.NavigationView
     app:itemShapeFillColor="@color/selector_menu"
     android:theme="@style/ThemeOverlay.NavigationView"
     ../>

where the selector has the pressed state

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:alpha="x.xx" android:color="...." android:state_pressed="true"/>

and the android:theme is used to override the color used but the ripple.

  <style name="ThemeOverlay.NavigationView" parent="">
    <item name="android:colorControlHighlight">@android:color/transparent</item>
  </style>

I don't know if there is a better way to achieve it but it could be useful to have an attribute to set the ripple on item in an easier way, something like app:itemRippleColor="....."

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 at NavigationView and inspect how itemShapeAppearance, itemShapeAppearanceOverlay, and the item ripple are applied. Check the existing XML attributes and related component tests or resources, if present. Done means an app can set an itemRippleColor attribute to control the item's ripple without the theme workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 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.