I am using TabLayout with viewPager and viewPager used RecyclerView to for it's fragment which extends FragmentStatePageAdapter.
This all is working fine. But, I have a scenario where i want to set the number of items to be fixed to only (7) for the tabLayout in scrollable mode (when tabMode is set to scrollable).
Somehow, it's only setting 5 items per device when tabLayout set to scrollable, but in my scenario i want it to adjust 7 items irrespective of any device.
I tried giving the item width as totalDeviceWidht/7 , but no luck as it's still taking the same widht.
I also tried overriding the onMeasure() method by writing a custom tabLayout. But, no luck.
I am not sure if the issue is with pagerTabStrip or how how viewPager and tabLayout calculates the number of items to be fixed when tabMode is set to scrollable.
I am stuck with this issue from last 3 days.
This is my main xml layout..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.movie.bms.views.activities.TimeActivity"
tools:showIn="@layout/activity_time"
>
<android.support.design.widget.TabLayout
android:id="@+id/time_sliding_tab"
android:layout_width="match_parent"
android:layout_height="61.8dp"
android:background="#06acef"
android:elevation="0dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
app:elevation="@dimen/elevation.small"
app:tabGravity="center"
app:tabIndicatorColor="@color/white"
app:tabMode="scrollable"
app:tabPaddingEnd="-1dp"
app:tabPaddingStart="-1dp"
android:fillViewport="false"
></android.support.design.widget.TabLayout>
<com.utils.customcomponents.CustomViewPager
android:id="@+id/time_view_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:transitionName="@string/event_body_transition">
</com.utils.customcomponents.CustomViewPager>
</LinearLayout>
Any kind of help or suggestion would be appreciated.