summaryrefslogtreecommitdiffstats
path: root/core/java/com/android/internal/widget/ScrollingTabContainerView.java
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2012-04-19 13:52:46 -0700
committerAdam Powell <adamp@google.com>2012-04-19 14:31:16 -0700
commitb8139af3dcae80c0030afd0354dc424a7c72c3d9 (patch)
tree3effb1da67632c3dcfe2008f32116c2331735fdf /core/java/com/android/internal/widget/ScrollingTabContainerView.java
parentf40a02f85f112e4b78fcea6f0d0390bfad15c2e2 (diff)
downloadframeworks_base-b8139af3dcae80c0030afd0354dc424a7c72c3d9.zip
frameworks_base-b8139af3dcae80c0030afd0354dc424a7c72c3d9.tar.gz
frameworks_base-b8139af3dcae80c0030afd0354dc424a7c72c3d9.tar.bz2
Adjust action bar tab policies
Action bar tabs now stack in portrait mode on all screen sizes rather than display embedded. This only affects apps with a targetSdkVersion of JB or greater, as older apps may not be prepared for the different measurement of the bar or have an appropriate stacked bar background drawable. Stacked action bar tabs now have a width limit. This prevents super-wide tabs that can span the whole screen. The cluster of tabs is centered if it does not span the full width. Add ActionBarPolicy to give a single point to query for various action bar measurements and behaviors that vary with configuration. Change-Id: I01162ca009c14f6f0e712fc906b9db6382c738cd
Diffstat (limited to 'core/java/com/android/internal/widget/ScrollingTabContainerView.java')
-rw-r--r--core/java/com/android/internal/widget/ScrollingTabContainerView.java20
1 files changed, 10 insertions, 10 deletions
diff --git a/core/java/com/android/internal/widget/ScrollingTabContainerView.java b/core/java/com/android/internal/widget/ScrollingTabContainerView.java
index 1767d68..83ac896 100644
--- a/core/java/com/android/internal/widget/ScrollingTabContainerView.java
+++ b/core/java/com/android/internal/widget/ScrollingTabContainerView.java
@@ -15,7 +15,7 @@
*/
package com.android.internal.widget;
-import com.android.internal.R;
+import com.android.internal.view.ActionBarPolicy;
import android.animation.Animator;
import android.animation.ObjectAnimator;
@@ -23,7 +23,6 @@ import android.animation.TimeInterpolator;
import android.app.ActionBar;
import android.content.Context;
import android.content.res.Configuration;
-import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.text.TextUtils.TruncateAt;
import android.view.Gravity;
@@ -55,6 +54,7 @@ public class ScrollingTabContainerView extends HorizontalScrollView
private boolean mAllowCollapse;
int mMaxTabWidth;
+ int mStackedTabMaxWidth;
private int mContentHeight;
private int mSelectedTabIndex;
@@ -69,10 +69,9 @@ public class ScrollingTabContainerView extends HorizontalScrollView
super(context);
setHorizontalScrollBarEnabled(false);
- TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.ActionBar,
- com.android.internal.R.attr.actionBarStyle, 0);
- setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
- a.recycle();
+ ActionBarPolicy abp = ActionBarPolicy.get(context);
+ setContentHeight(abp.getTabContainerHeight());
+ mStackedTabMaxWidth = abp.getStackedTabMaxWidth();
mTabLayout = createTabLayout();
addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
@@ -93,6 +92,7 @@ public class ScrollingTabContainerView extends HorizontalScrollView
} else {
mMaxTabWidth = MeasureSpec.getSize(widthMeasureSpec) / 2;
}
+ mMaxTabWidth = Math.min(mMaxTabWidth, mStackedTabMaxWidth);
} else {
mMaxTabWidth = -1;
}
@@ -187,6 +187,7 @@ public class ScrollingTabContainerView extends HorizontalScrollView
final LinearLayout tabLayout = new LinearLayout(getContext(), null,
com.android.internal.R.attr.actionBarTabBarStyle);
tabLayout.setMeasureWithLargestChildEnabled(true);
+ tabLayout.setGravity(Gravity.CENTER);
tabLayout.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT));
return tabLayout;
@@ -205,12 +206,11 @@ public class ScrollingTabContainerView extends HorizontalScrollView
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
+ ActionBarPolicy abp = ActionBarPolicy.get(getContext());
// Action bar can change size on configuration changes.
// Reread the desired height from the theme-specified style.
- TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.ActionBar,
- com.android.internal.R.attr.actionBarStyle, 0);
- setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
- a.recycle();
+ setContentHeight(abp.getTabContainerHeight());
+ mStackedTabMaxWidth = abp.getStackedTabMaxWidth();
}
public void animateToVisibility(int visibility) {