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

[TabLayout] Width of first tab is incorrect on some devices

Open
#1,856 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

**Description:** A `TabLayout` which has a `tabMode` value of `fixed` and a `tabGravity` value of `fill` (as in the layout file [here](https://github.com/adil-hussain-84/TabLayoutExperiments/blob/master/app1/src/main/res/layout/activity_main.xml)) results in the first tab rendering with a width of `264dp` on some devices rather than its natural width, as [this](https://github.com/adil-hussain-84/TabLayoutExperiments/blob/master/app1/screenshots/TabLayoutBugScreenshot.png) screenshot demonstrates.

**Expected behavior:** The first tab should have a natural width like the other two tabs in the `TabLayout` rather than a width of `264dp` (which, curiously, is the value of the `design_tab_max_width` dimension in the `com.google.android.material:material` library).

**Source code:** See [this](https://github.com/adil-hussain-84/TabLayoutExperiments/tree/master/app1) minimal Android application which demonstrates the problem.

**Android API version:** Android 10

**Material Library version:** 1.2.1

**Device:** Moto G8 Plus landscape orientation

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 with the linked minimal Android application and reproduce the TabLayout behavior on Android 10 in landscape with fixed tabMode and fill tabGravity. Then trace the material library's TabLayout implementation and compare the first tab's width with the expected natural widths; done means the supplied reproduction no longer gives the first tab a 264dp width.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
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.