Skip to content Skip to sidebar Skip to footer

Tabmode="scrollable" Not Working

I am using the TabLayout from Android Design support library. I am using material design theme. Below is the code activity_scrollable_Tab.xml

Solution 1:

Maybe you should set that tab mode programmatically? Try to call setTabMode method on TabLayaut instance tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);

I don't know why it doesn't work for you, but I tested these modes few weeks ago, and for me scrollable mode worked on all Android versions.

Also check if you use the latest version of Design Support Library, maybe you use some previous bugged version?

Solution 2:

To make Tab scrollable work in kitkat and Jelly bean devices you can refer this tutorial

http://www.android4devs.com/2015/01/how-to-make-material-design-sliding-tabs.html

Google docs is also there for this https://developer.android.com/samples/SlidingTabsBasic/src/com.example.android.common/view/SlidingTabLayout.html

It is well tested and working for me on all devices

Solution 3:

My case is some thing different which is not solved by most of the answers i tried.

The answer is add xmlns:app="http://schemas.android.com/apk/res-auto" in your android.support.design.widget.CoordinatorLayout.

I am posting the complete code here,

<android.support.design.widget.CoordinatorLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"><android.support.design.widget.AppBarLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"><android.support.v7.widget.Toolbarandroid:id="@+id/toolbar"android:layout_width="match_parent"android:layout_height="?attr/actionBarSize"android:background="?attr/colorPrimary"app:layout_scrollFlags="scroll|enterAlways"app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /><android.support.design.widget.TabLayoutandroid:id="@+id/tabs"android:layout_width="match_parent"android:layout_height="wrap_content"app:tabMode="scrollable"/></android.support.design.widget.AppBarLayout><android.support.v4.view.ViewPagerandroid:id="@+id/viewpager"android:layout_width="match_parent"android:layout_height="match_parent"app:layout_behavior="@string/appbar_scrolling_view_behavior" /></android.support.design.widget.CoordinatorLayout>

After adding xmlns:app="http://schemas.android.com/apk/res-auto" in my TabLayout xml file, Tab scroll function working fine in Jelly bean, Kitkat and lollipop.

Solution 4:

Please try below xml for your TabLayout.

<android.support.design.widget.TabLayout
android:id="@+id/tabs"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center_horizontal"app:tabMode="scrollable" />

Solution 5:

Your FragmentPagerAdapter looks a little weird, why are you adding your fragments to a List? Have you tried adding

adapter.notifyDataSetChanged();

before

viewPager.setAdapter(adapter);

on setupViewPager?

Post a Comment for "Tabmode="scrollable" Not Working"