我有以下代码,您可以看到我只有两个选项:
TabLayout.GRAVITY_CENTER
TabLayout.GRAVITY_FILL
两者都不像我想在图像上实现的。
SectionsPagerAdapter sectionsPagerAdapter = new
SectionsPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(sectionsPagerAdapter);
tabLayout.setupWithViewPager(viewPager);
tabLayout.getTabAt(0).setIcon(R.mipmap.ic_whatshot_white_24dp).setText("Tendencias");
tabLayout.getTabAt(1).setIcon(R.mipmap.ic_cake_white_24dp).setText("Cercanos");;
tabLayout.getTabAt(0).getIcon().setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
tabLayout.getTabAt(1).getIcon().setColorFilter(Color.parseColor("#1e564f"), PorterDuff.Mode.SRC_IN);
tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER);