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

[CardView + Button] Support for dashed strokes

Open
#1,643 0 comments 17 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

**Describe the solution you'd like**
Basically, any component that currently uses `strokeColor` and `strokeWidth` (I've listed the ones that I know support strokes), would be nice to be able to set the stroke as dashed/dotted. Shown in the screenshot below.

Perhaps an extra `strokeDashWidth` attr that is only used when set. Presumably easy to implement by just optionally adding a `DashPathEffect` to the stroke paint inside `MaterialShapeDrawable`, although I could be wrong.

**Describe alternatives you've considered**
Could use a custom Drawable, either programatically, a nine-patch or potentially a ShapeDrawable?

**Additional context**
Example use case, admittedly a rare one but would be nice to have.

[Left most screenshot](https://static.dribbble.com/users/4839201/screenshots/14044222/media/b3fcb7039dedf36014d4c57f2c60d4d8.png)

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 locating MaterialShapeDrawable and the CardView and Button components that use strokeColor and strokeWidth. Review how stroke paint is configured, then determine the API needed to support dashed or dotted strokes without affecting existing solid strokes. Done means the supported stroke components can render the requested dash pattern when configured.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.