astuetz / PagerSlidingTabStrip

An interactive indicator to navigate between the different pages of a ViewPager
139 stars 44 forks source link

Tab text may be clipped when shouldExpand is true #82

Open magicgoose opened 10 years ago

magicgoose commented 10 years ago

Tested on Sony Xperia L. When in landscape mode, and there are 4 tabs with different text length (about 1-2 words), the library may decide that they all can fit in the screen and the tab with the longest text inside gets clipped text.

icarovirtual commented 10 years ago

Can confirm this bug. Happened to me on my Nexus 4, in portrait mode. bug

With shouldExpand set to false the text is not clipped.

doridori commented 10 years ago

Im also seeing this on a Nexus 4 with 4 tabs - im only getting when i switch from all upper case to lower case - presumably the width is shortened just enough for the custom view layout to think that they can all fit on one screen without scrolling

ivanjr0 commented 10 years ago

Same problem here! Do you guys have any news?

OnlyInAmerica commented 10 years ago

If you call mPagerSlidingTabStrip.setTabPaddingLeftRight(0); the text will fill the tab instead of clipping.

jhondge commented 9 years ago

Same problem here! It looks like a LinearLayout measure bug,Is any one fixed this bug?

peitek commented 9 years ago

@OnlyInAmerica 's tip of calling .setTabPaddingLeftRight(0); fixed it for me.

midaslefkowitz commented 9 years ago

I created a minihack based on the suggested bug fix found here :

LinearLayout tabsContainer = (LinearLayout) tabStrip.getChildAt(0);
for (int i=0; i < tabsContainer.getChildCount(); i++) {
    TextView tab = (TextView)tabsContainer.getChildAt(i);
    tab.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f));
}

You might also want to add left and right padding to the tabs while you are at it. in which case the code would be (I added an 8px padding):

LinearLayout tabsContainer = (LinearLayout) tabStrip.getChildAt(0);
for (int i=0; i < tabsContainer.getChildCount(); i++) {
    TextView tab = (TextView)tabsContainer.getChildAt(i);
    tab.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f));
    tab.setPadding(8,0,8,0);
}