According to Material design guidelines ,In android.support.design.widget.TabLayout when there are many tabs which cannot fit the screen size we can use overflow pagination , by providing a right arrow which when clicked will show all the remaining tabs by scrolling horizontally.How to achieve this?
[Here's an image of the same given in guidelines]
That pattern is in the 'Desktop tabs' section and therefore not supported by TabLayout
, which is specifically targeting the 'Mobile tabs' section.
You have to set the tabMode to scrollable in the XML file
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"/>
Unable to add pagination arrows but was able to add scrolling to tabview:
Surround your tabview with HorizontalScrollView and LinearLayout:
<HorizontalScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_weight="1"
android:fadingEdgeLength="20dp"
android:scrollbars="none" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?actionBarSize"
app:tabGravity="fill"
app:tabIndicatorColor="@color/white"
app:tabIndicatorHeight="4dp"
app:tabBackground="@color/colorPrimary"
app:tabMode="scrollable"
android:overScrollMode="never"
android:visibility="visible">
</android.support.design.widget.TabLayout>
</LinearLayout>
</HorizontalScrollView>