Home » Android » text – How to stop titles in Android tabs from wrapping in the middle of a word?

text – How to stop titles in Android tabs from wrapping in the middle of a word?

Posted by: admin June 15, 2020 Leave a comment


I have a layout with several tabs. What’s happening is that in landscape orientation, the layout is wrapping the text used in the tab titles, but not on a word – its wrapping in the middle of a word! So a title like:


looks fine in portrait but in landscape is shown like this:


I’m not specifying any word wrap or style attributes for the text. I would imagine the layout would have more space in landscape mode than portrait, so this makes no sense. Would appreciate any advice on what to look at.

How to&Answers:

Late response, but Google brought me here, so this might be useful still.

You can choose to scroll the tabs, which I believe is preferable to changing font sizes.




  • Do you use the same layout file for landscape and portrait?
  • Are the width of your tabs set to wrap_content?
  • Try setting singleLine="true" on the tab text
  • Does the width of the tab graphic increase when changed to landscape?
  • Are you using a custom background on the tabs and if so is it a nine-patch?

Although TBH I usually use a RadioGroup and a FrameLayout to achieve tabs because it provides more control (you can’t change the tab strip drawable prior to 2.2, and using this method your tabs can be separated from the tab content so you can put either wherever you want).


OK, we managed to fix this. Had to reduce font size by 1pt size and reduce left+right padding on tabs. We also noticed that in landscape the tabs were all the same size but in portrait they weren’t, so obviously somewhere we had a fill_parent instead of a wrap_content. Fix seems to work for both 7″ and 10″ tablets. Thanks for the assist.


You Can Manage this, with

Override this class in project ActionBarSherlock ./ActionbarSherlock/src/com/actionbarsherlock/internal/widget/ScrollingTabContainerView.java

public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    if (mParent.mMaxTabWidth > 0 && getMeasuredWidth() > mParent.mMaxTabWidth) {

        //comment this line

       // super.onMeasure(MeasureSpec.makeMeasureSpec(mParent.mMaxTabWidth, MeasureSpec.EXACTLY),heightMeasureSpec);

       //now do nothing , override by me for ActionBarTabs not rezize never
      //this method manage the size tabs, if you want you can count caracters to resize the size width