1

I have made a tablayout with a viewpager and am using the tablayout in scrollable mode:

    <android.support.design.widget.TabLayout
    android:id="@+id/tab_layout_movie"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/toolbar"
    android:background="?attr/colorPrimary"
    android:elevation="6dp"
    android:minHeight="?attr/actionBarSize"
    app:tabMode="scrollable"

    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>

Problem comes when there are very few tabs to display, here the tabs do not fit the screen. I have tried setting maxWidth to 0dp and tabGravity=fill and center to no avail...

This is not an issue with actually more number of tabs.enter image description here

Kushan
  • 5,855
  • 3
  • 31
  • 45
  • I know, i read that question, it did not help me, please help me find an actual solution to this... – Kushan Aug 16 '16 at 23:08
  • 1
    have you tried implementing the accepted answer? – Robbe Aug 16 '16 at 23:10
  • I mean other than overriding the view. The issue is that number of tabs will vary depending on my data from my server – Kushan Aug 16 '16 at 23:10
  • Anyway I'll try it out, will post a query if it doesn't work, ciao – Kushan Aug 16 '16 at 23:12
  • You can use it with a varying number of tabs. Just add `if (field.get(this) < getMeasuredWidth() / getTabCount())` above the `field.set(...)` method. And change `mTabMinWi‌​dth` to `mScrollableTabMinWi‌​dth`(see comments) – Robbe Aug 16 '16 at 23:20
  • @Robbe could you check out my question please, the custom class isn't helping :( http://stackoverflow.com/questions/39002684/tabs-dont-fit-to-screen-with-tabmode-scrollable-even-with-a-custom-tab-layout – Kushan Aug 17 '16 at 17:19

0 Answers0