I've tried adding the divider between tabs, without using any custom layout. I have tried it programmatically using the following method:
public static void addTabsDividers(TabLayout tabLayout, @ColorRes int divColorRes,int divWidthDP,int divHeightDP){
View root = tabLayout.getChildAt(0);
if (root instanceof LinearLayout) {
((LinearLayout) root).setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
GradientDrawable drawable = new GradientDrawable();
drawable.setColor(tabLayout.getContext().getResources().getColor(divColorRes));
drawable.setSize(divWidthDP, divHeightDP);
// ((LinearLayout) root).setDividerPadding(10);
((LinearLayout) root).setDividerDrawable(drawable);
}
}
but this adds extra space in left side of tabs:
Notice the strange white space on left side of tabs, I want to remove that !!
Tabs xml:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="?actionBarSize">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/tabs"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<FrameLayout
android:id="@+id/fl_main"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
app:tabIndicatorColor="@color/colorPrimary"
app:tabPaddingTop="5dp"
app:tabPaddingBottom="0dp"
app:tabPaddingStart="0dp"
app:tabPaddingEnd="0dp"
app:tabTextColor="@color/md_white_1000"
app:tabSelectedTextColor="@color/md_white_1000"
app:tabTextAppearance="@style/TabTextStyle"
app:tabBackground="@drawable/tab_color_selector"/>
</RelativeLayout>