9

I am wondering about how to change the tab width in Pager Tab Strip

I have browse but it is like there are no one encountering the same problem as me..

My current layout is look like this:

BigWidthTab

But i am wondering how to create the tab that has small width like this with PageTabStrip

SmallWidthTab

Most of them are using external library like ViewPagerIndicator

Is it possible to do it with PageTabStrip? Thanks Here is my current code

     <android.support.v4.view.ViewPager
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

       <android.support.v4.view.PagerTabStrip
         android:id="@+id/pagerTabStrip"
         android:layout_width="match_parent"
         android:layout_height="30dp"
         android:textColor= "@color/white"
         android:layout_gravity="top" >
       </android.support.v4.view.PagerTabStrip>

     </android.support.v4.view.ViewPager>
Community
  • 1
  • 1
AlbertSamuel
  • 584
  • 10
  • 33
  • 2
    Hi! Did you find a solution? I'm facing the same problem here :/ About the width and in my case I want to put the selected tab always on the left – Caique Jul 01 '14 at 20:40
  • 1
    @Caique hi there, sorry but i didnt find any solution.. The best solution i can offer is using external library.. Thanks! – AlbertSamuel Jul 03 '14 at 00:46
  • Have you tried setting the text spacing? That could be of help. setTextSpacing api on the PagerTabStrip – mistwalker Apr 20 '15 at 18:08
  • Your question was answered here: http://stackoverflow.com/questions/27577667/pagertabstrip-tabs-alignment-to-left – chr1st3nd0 Aug 04 '15 at 14:44
  • 1
    Possible duplicate of [PagerTabStrip tabs alignment to left](http://stackoverflow.com/questions/27577667/pagertabstrip-tabs-alignment-to-left) – Entreco Feb 14 '17 at 22:16
  • Thank you for noticing @chr1st3nd0 – AlbertSamuel Feb 16 '17 at 04:08

1 Answers1

1

The Question is answered here: PagerTabStrip tabs alignment to left

Use this before setViewPager():

sliding_tabs.setDistributeEvenly(true);
Community
  • 1
  • 1
AlbertSamuel
  • 584
  • 10
  • 33