1515 */
1616package com .android .internal .widget ;
1717
18- import com .android .internal .R ;
18+ import com .android .internal .view . ActionBarPolicy ;
1919
2020import android .animation .Animator ;
2121import android .animation .ObjectAnimator ;
2222import android .animation .TimeInterpolator ;
2323import android .app .ActionBar ;
2424import android .content .Context ;
2525import android .content .res .Configuration ;
26- import android .content .res .TypedArray ;
2726import android .graphics .drawable .Drawable ;
2827import android .text .TextUtils .TruncateAt ;
2928import android .view .Gravity ;
@@ -55,6 +54,7 @@ public class ScrollingTabContainerView extends HorizontalScrollView
5554 private boolean mAllowCollapse ;
5655
5756 int mMaxTabWidth ;
57+ int mStackedTabMaxWidth ;
5858 private int mContentHeight ;
5959 private int mSelectedTabIndex ;
6060
@@ -69,10 +69,9 @@ public ScrollingTabContainerView(Context context) {
6969 super (context );
7070 setHorizontalScrollBarEnabled (false );
7171
72- TypedArray a = getContext ().obtainStyledAttributes (null , R .styleable .ActionBar ,
73- com .android .internal .R .attr .actionBarStyle , 0 );
74- setContentHeight (a .getLayoutDimension (R .styleable .ActionBar_height , 0 ));
75- a .recycle ();
72+ ActionBarPolicy abp = ActionBarPolicy .get (context );
73+ setContentHeight (abp .getTabContainerHeight ());
74+ mStackedTabMaxWidth = abp .getStackedTabMaxWidth ();
7675
7776 mTabLayout = createTabLayout ();
7877 addView (mTabLayout , new ViewGroup .LayoutParams (ViewGroup .LayoutParams .WRAP_CONTENT ,
@@ -93,6 +92,7 @@ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
9392 } else {
9493 mMaxTabWidth = MeasureSpec .getSize (widthMeasureSpec ) / 2 ;
9594 }
95+ mMaxTabWidth = Math .min (mMaxTabWidth , mStackedTabMaxWidth );
9696 } else {
9797 mMaxTabWidth = -1 ;
9898 }
@@ -187,6 +187,7 @@ private LinearLayout createTabLayout() {
187187 final LinearLayout tabLayout = new LinearLayout (getContext (), null ,
188188 com .android .internal .R .attr .actionBarTabBarStyle );
189189 tabLayout .setMeasureWithLargestChildEnabled (true );
190+ tabLayout .setGravity (Gravity .CENTER );
190191 tabLayout .setLayoutParams (new LinearLayout .LayoutParams (
191192 LinearLayout .LayoutParams .WRAP_CONTENT , LinearLayout .LayoutParams .MATCH_PARENT ));
192193 return tabLayout ;
@@ -205,12 +206,11 @@ private Spinner createSpinner() {
205206 protected void onConfigurationChanged (Configuration newConfig ) {
206207 super .onConfigurationChanged (newConfig );
207208
209+ ActionBarPolicy abp = ActionBarPolicy .get (getContext ());
208210 // Action bar can change size on configuration changes.
209211 // Reread the desired height from the theme-specified style.
210- TypedArray a = getContext ().obtainStyledAttributes (null , R .styleable .ActionBar ,
211- com .android .internal .R .attr .actionBarStyle , 0 );
212- setContentHeight (a .getLayoutDimension (R .styleable .ActionBar_height , 0 ));
213- a .recycle ();
212+ setContentHeight (abp .getTabContainerHeight ());
213+ mStackedTabMaxWidth = abp .getStackedTabMaxWidth ();
214214 }
215215
216216 public void animateToVisibility (int visibility ) {
0 commit comments