Is there a way to add margin between the tabs in a TabLayout? I\'ve tried with using a custom style for Widget.Design.TabLayout, but there are properties on
@Todor Kostov answered well, but the center of the tabs are slipped away because the last tab has margin too.
so use mTabLayout.getTabCount() - 1 instead of just mTabLayout.getCodeCount().
for(int i=0; i < mTabLayout.getTabCount() - 1; i++) {
View tab = ((ViewGroup) mTabLayout.getChildAt(0)).getChildAt(i);
ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) tab.getLayoutParams();
p.setMargins(0, 0, 50, 0);
tab.requestLayout();
}