Hello I have created a tab layout in my activity. This is the main .xml file:
The answer given by @Tjerkw is ok just that it doesn't loop through the entire tab. I guess the right solution should be this
for (int i = 0; i < tabLayout.getTabCount(); i++ ) {
yourlinearlayout = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.title_text, null);
tab_text = (TextView) yourlinearlayout.findViewById(R.id.tabContent);
tab_text.setText(" " + tab_titles[i]);
tab_text.setCompoundDrawablesWithIntrinsicBounds(tabicons[i], 0, 0, 0);
tabLayout.getTabAt(i).setCustomView(tab_text);}
and the layout resource .xml representing R.layout.title_text will be
finally, the tabicons[i] and tab tab_titles[i] are just String arrays containing their respective contents.
I know this question's old but i recently faced this and i'm sure someone else might still need this