material-components / material-components/material-components-android
[NavigationView] Attribute to se the ripple color on items
Nobody has claimed this yet.
- 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.
In same cases it could be useful to have a selector with the same shape and without the grey ripple on background.
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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