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

[TabLayout] Support better break strategies for tab text.

Open
#4,616 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Is your feature request related to a problem? Please describe.
I have a TabLayout with four items in fixed mode. This means that on some devices, the text of some items ends up being too long and therefore breaks on to a second line. Since the text is only a single word though, it has to break in the middle of a word. With the current behaviour it does so without adding a hyphen/dash and in weird places.

Describe the solution you'd like
I would like to be able to set the break strategy, similar to how it can be set for a TextView.

Describe alternatives you've considered
I have considered making the tabs have 1 line maximum to prevent the line breaks entirely, but as far as I could figure out, the maxLines value is hardcoded in this library and can't be changed from implementors of this library. I have also considered setting the mode to auto or scrollable, however both produce unwanted effects when there would be enough space (these issues are already covered by #650).

Additional context
In this screenshot you can see, that it sometimes puts just a single character on a new line.

Image

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

No file or test is named. Start by locating TabLayout's fixed-mode tab text setup and its existing maxLines handling, then compare the desired configuration with TextView's break-strategy behavior. Done means fixed tabs can use a selectable break strategy and no longer split single-word labels at unsuitable points.

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.