Material-components-android: Add tabs adapter for TabLayout

Created on 22 Feb 2017  路  1Comment  路  Source: material-components/material-components-android

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.

Most helpful comment

It's been two years, are there any updates on this?

>All comments

It's been two years, are there any updates on this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KelvinPac picture KelvinPac  路  3Comments

gabrielemariotti picture gabrielemariotti  路  3Comments

JavierSegoviaCordoba picture JavierSegoviaCordoba  路  3Comments

JakeWharton picture JakeWharton  路  3Comments

Mirmuhsin picture Mirmuhsin  路  3Comments