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

[TabLayout] Add XML attribute for scrollableTabMinWidth

Open
#1,557 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'm attempting to get centered, scrollable tabs with NO minimum width. However, it seems that a minimum width is added to each tab when `tabMode="scrollable"`.

**Describe the solution you'd like**
I'd like to be able to remove, or set the minimum width to zero. There's possibly already a TODO for this on Line 570 of the class.

**Describe alternatives you've considered**
I've tried different combinations of `tabMode` and `tabGravity`:
```
// 1 This produces the desired visual result when tab labels are smaller than screen width (pictured)
// but results in multi-line tabs when the labels are wider than the screen width.

tabMode="fixed"
tabGravity="start"
```
![fixed_start_tabs](https://user-images.githubusercontent.com/60164509/89096747-ad537a00-d38d-11ea-821f-9f7cb06fd5d5.png)

```
// 2 These seem to be the desired attribute values, but a minimum width is applied to each tab.

tabMode="scrollable"
tabGravity="center"
```
![scrollable_center_tabs](https://user-images.githubusercontent.com/60164509/89096751-b5131e80-d38d-11ea-85c6-f27f990f3f48.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 in the TabLayout class at the TODO around line 570 and trace how the minimum width is applied when tabMode="scrollable". Add the requested XML attribute so the minimum can be set to zero, then verify that centered scrollable tabs no longer receive the unwanted minimum width.

Written by the indexing model from the issue text.

Assessment

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