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

[TabLayout] Support gravity_fill with "auto" mode

Aperta
#650 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

feature request Widget: Tab
Lingua principale
Java
Stelle
17.4k
Fork
3.2k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

**Description:** Setting the `tabMode` to `auto` is the same as setting the `tabMode` to `scrollable`. Even if there are only 2 items, they will never act like `fixed` tabs.

**Expected behavior:**
Expected to act as in [the documentation](https://developer.android.com/reference/com/google/android/material/tabs/TabLayout.html#MODE_AUTO)
> Auto-sizing tabs behave like MODE_FIXED with GRAVITY_CENTER while the tabs fit within the TabLayout's content width. Fixed tabs have equal width, based on the widest tab label. Once the tabs outgrow the view's width, auto-sizing tabs behave like MODE_SCROLLABLE, allowing for a dynamic number of tabs without requiring additional layout logic.

**Source code:**
By adding `app:tabMode="auto"` to the `tab_layout` view in `component_tabs.xml` and running the Material Theme Builder, you can see that the tabs no longer take up the full width of the parent. This occurs regardless of whether the parent is a LinearLayout or ConstraintLayout.

In [`updateTabViewLayoutParams` in `TabLayout`](https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/tabs/TabLayout.java#L1568), it sets the `tabView` layout params' width to `WRAP_CONTENT` if the mode is not `MODE_FIXED`, not sure if that's the issue.

**Android API version:**
Seen on API 29.

**Material Library version:**
Seen on alpha07, alpha09, and alpha10.

**Device:**
Seen on Pixel 3 emulator.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia in lib/java/com/google/android/material/tabs/TabLayout.java, all’interno di updateTabViewLayoutParams, quindi riproduci il comportamento impostando app:tabMode="auto" in component_tabs.xml ed eseguendo Material Theme Builder. Confronta il risultato con il comportamento documentato di MODE_AUTO per due schede sia in parent LinearLayout sia in parent ConstraintLayout; il lavoro è completato quando le schede che rientrano si comportano come schede fisse e quelle che eccedono rimangono scorrevoli.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
mobile
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.