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

Add tabs adapter for TabLayout

Aperta
#32 1 commento 10 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

TabLayout creates the tabs in an opaque, non-extensible way and there is no way to provide a custom view at creation time, you have to hack around it with an observer set on the content source (e.g., a ViewPager adapter) and then use setCustomView() on each tab, after they're created.

Besides, the way tabs' views are created prevents libraries such as Calligraphy from correctly applying a typeface to the default tab views, because the TextAppearance is applied only after inflating the view, and there's no way to access the tabs pool nor any hook into the creation of new tabs.

Suggested changes

Have a mechanism to create and bind the tabs' views, similar to list adapters, that have a createTabView() and a bindTabView() methods. The default implementation would simply retain the current behaviour; users could extend the default implementation to tweak the tabs' appearance (e.g., CalligraphyUtils.applyFontToTextView(tabTextView, typeface);) or to inflate their custom tab views without the waste of always inflating the default layout anyways.

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 dal percorso di creazione delle schede descritto nell’issue, inclusa la sua interazione con un adapter di ViewPager. Definisci come createTabView() e bindTabView() conserverebbero il comportamento predefinito consentendo al contempo viste personalizzate e l’applicazione del typeface; il lavoro è completo quando i chiamanti possono personalizzare la creazione senza osservare la sorgente del contenuto né inflatare un layout predefinito inutilizzato.

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

Valutazione

Stack tecnologico
android, java
Ambito
mobile
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.