14

The TabLayout is quite userful building a sliding tab for viewpager, except there is no way you can add vertical line between tabs just like TabHost in code or xml as far as I know, so is there other way to do so with ease?

KNOX.C
  • 323
  • 1
  • 2
  • 11
  • You can try below link for solving your problem. Link : http://stackoverflow.com/questions/32204184/how-to-set-the-divider-between-tabs-in-tablayout-of-design-support-library?lq=1 – KishuDroid Sep 25 '15 at 07:03

2 Answers2

55

TabLayout is actually a horizontal scrollable LinearLayout.

Just use following code to add dividers:

    LinearLayout linearLayout = (LinearLayout)tabLayout.getChildAt(0);
    linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
    GradientDrawable drawable = new GradientDrawable();
    drawable.setColor(Color.GRAY);
    drawable.setSize(1, 1);
    linearLayout.setDividerPadding(10);
    linearLayout.setDividerDrawable(drawable);
kim
  • 1,057
  • 11
  • 11
0

try this,

You can add manually line in your tab_indicator layout file.

for Horizontal line,

<View
    android:layout_height="1dp"
    android:id="@+id/line"
     android:layout_width="fill_parent"
      android:background="your color" />

and for Vertical line

<View
    android:layout_height="7dp"
    android:id="@+id/line"
     android:layout_width="1dp"
      android:background="your color" />
Ganpat Kaliya
  • 888
  • 2
  • 9
  • 16