Here is my code:
private TabLayout tabLayout;
private int[] tabIcons = {
R.mipmap.ic_compass,
R.mipmap.ic_place,
R.mipmap.ic_passport,
R.mipmap.ic_setting
};
...
tabLayout.getTabAt(0).setIcon(tabIcons[0]);
tabLayout.getTabAt(1).setIcon(tabIcons[1]);
tabLayout.getTabAt(2).setIcon(tabIcons[2]);
tabLayout.getTabAt(3).setIcon(tabIcons[3]);
The size of icon is according to image size. How could I resize it?
set icons padding
for (int i = 0; i < tablayout.getTabWidget().getChildCount(); i++)
{
tablayout.getTabWidget().getChildAt(i).setPadding(10,10,10,10);
}