How can I prevent word wrap in tab bar items in Holo theme?

My app works with Theme.Light at API level 10 and below and Holo.Light at API level 11 and above. The tab bar in Theme Light displays all items without word wrapping, but the Holo theme wraps them in the middle of a word:

holo theme screenshot

How can I prevent this?

+3


source to share


2 answers


Have you tried using the attribute android:ellipsize

in xml or setEllipsize(TextUtils.TruncateAt)

in a view that contains text? If the view inherits or is a textual view that should work. "If set, invokes words that are longer than sight, wide to be ellipsis rather than broken down the middle." Perhaps you can set the TextView as TabSpec withpublic TabHost.TabSpec setIndicator (View view)



0


source


You can control it,

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



@Override
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
    }
}

      

0


source







All Articles