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

Add tabs adapter for TabLayout

Offen
#32 1 Kommentar 10 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

feature request
Vorherrschende Sprache
Java
Sterne
17.4k
Forks
3.2k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

`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](https://github.com/chrisjenx/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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne beim im Issue beschriebenen Pfad zur Tab-Erstellung, einschließlich seiner Interaktion mit einem ViewPager-Adapter. Lege fest, wie createTabView() und bindTabView() das Standardverhalten beibehalten und gleichzeitig benutzerdefinierte Ansichten sowie die Anwendung einer Schriftart ermöglichen; als abgeschlossen gilt die Arbeit, wenn Aufrufer die Erstellung anpassen können, ohne die Inhaltsquelle zu inspizieren oder ein ungenutztes Standardlayout zu inflaten.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
android, java
Bereich
mobile
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.