You can extend TabLayout to provide your own view for tabs.
public class CustomTabLayout extends TabLayout {
public CustomTabLayout (final Context context) {
super(context);
}
public CustomTabLayout (final Context context, final AttributeSet attrs) {
super(context, attrs);
}
public CustomTabLayout (final Context context, final AttributeSet attrs, final int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void setTabsFromPagerAdapter(@NonNull final PagerAdapter adapter) {
removeAllTabs();
int i = 0;
final LayoutInflater inflater = LayoutInflater.from(getContext());
for(int count = adapter.getCount(); i < count; ++i) {
final TextView tab = (TextView) inflater.inflate(R.layout.custom_tab, this, false);
tab.setText(local.getPageTitle(i));
this.addTab(this.newTab().setCustomView(tab));
}
}
}