14
TabLayout provides a horizontal layout
to display tabs, and is commonly used in conjunction with a ViewPager.
Make sure the following dependency
is added to your app's build.gradle file under dependencies:
compile 'com.android.support:design:25.3.1'
Now you can add items
to a TabLayout in your layout using the TabItem class.
For example:
Add an OnTabSelectedListener to be notified when a tab in the TabLayout is selected/unselected/reselected:
Tabs can also be added/removed from the TabLayout programatically.
TabLayout has two modes, fixed and scrollable.
e: the TabLayout modes are mutually exclusive, meaning only one can be active at a time.
The tab indicator color is the accent color defined for your Material Design
theme.
You can override this color by defining a custom style in styles.xml and then applying the style to your TabLayout: