I have problems trying to add a line under TabLayout, but it should be behind the selector line. There should be something like this:

I already tried to add a custom view, but there is a field inside each tab, so nothing worked.
any ideas?
Here is what I got right now:

This is how I add it to XML:
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="60dp"
app:tabBackground="@color/white"
app:tabIndicatorColor="@color/colorAccent"
app:tabTextColor="@color/white"/>
and this is what I do with the code:
private void configureTabLayout() {
TabLayout.Tab tabHome = mTabLayout.newTab().setIcon(R.drawable.ic_home_cinza);
TabLayout.Tab tabEmprestimos = mTabLayout.newTab().setIcon(R.drawable.ic_emprestimos_cinza);
TabLayout.Tab tabPersonal = mTabLayout.newTab().setIcon(R.drawable.ic_usuario_cinza);
View root = mTabLayout.getChildAt(0);
if (root instanceof LinearLayout) {
((LinearLayout) root).setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
GradientDrawable drawable = new GradientDrawable();
drawable.setColor(getResources().getColor(R.color.silver));
drawable.setSize(2, 1);
((LinearLayout) root).setDividerPadding(10);
((LinearLayout) root).setDividerDrawable(drawable);
}
mTabLayout.addTab(tabHome);
mTabLayout.addTab(tabEmprestimos);
mTabLayout.addTab(tabPersonal);
mTabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
}
source
share