material-components / material-components/material-components-android
Add tabs adapter for TabLayout
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
`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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the TabLayout tab-creation path described in the issue, including its interaction with a ViewPager adapter. Define how createTabView() and bindTabView() would preserve the default behavior while allowing custom views and typeface application; done means callers can customize creation without observing the content source or inflating an unused default layout.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100