Add onTabSelectedListener to your tabLayout to set text dynamically.
so in this approach when tab will be selected text will become "selected" or other tab
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
tab.getCustomView().setAlpha(1.0f);
((TextView) tab.getCustomView()).setTextSize(12);
((TextView) tab.getCustomView()).setText("Selected");
Log.d("TabBar", "selected");
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
tab.getCustomView().setAlpha(0.3f);//to set alpha
((TextView) tab.getCustomView()).setTextSize(11);
((TextView) tab.getCustomView()).setText("DeSelected");
Log.d("TabBar", "unselected");
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
Log.d("TabBar", "reselected");
}
});
to set tab as default selected then use this statement
tabLayout.getTabAt(0).select(); //this is used to set tab as default