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?
Tab layout are visible below toolbar with View pager, used to create swipeable views . Tabs are designed to work with fragments. Use them to swipe fragments in view pager.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With