I have TabLayout with tabGravity set to fill
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabBackground="@drawable/tab_background"
app:tabGravity="fill"
app:tabIndicatorHeight="0dp"
app:tabMaxWidth="0dp"
app:tabMode="fixed" />
and want to add a custom divider between tabs. I tried this method
View root = tabLayout.getChildAt(0);
LinearLayout linearLayout = (LinearLayout) root;
linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
GradientDrawable drawable = new GradientDrawable();
drawable.setColor(Color.WHITE);
drawable.setSize(5, 0);
linearLayout.setDividerDrawable(drawable);
It works fine except beginning of the first tab. I'm using SHOW_DIVIDER_MIDDLE
but the first tab has margin at the left:
If I remove dividers, margin disappears. How to get rid of the margin but keep dividers?
Here is the full test project: https://github.com/PiN73/TestDivider