Make the minitabs stretch to fit the available space.
Change-Id: Ifd2b774b40e2831f4f2326c0fe9ebbb3e7d714d0
diff --git a/src/com/android/contacts/BaseContactCardActivity.java b/src/com/android/contacts/BaseContactCardActivity.java
index f123c89..2aac1a2 100644
--- a/src/com/android/contacts/BaseContactCardActivity.java
+++ b/src/com/android/contacts/BaseContactCardActivity.java
@@ -205,7 +205,7 @@
// TODO: ensure inflation on background task so we don't block UI thread here
final ContactsSource source = sources.getInflatedSource(accountType,
ContactsSource.LEVEL_SUMMARY);
- addTab(rawContactId, createTabIndicatorView(mTabWidget, source));
+ addTab(rawContactId, createTabIndicatorView(mTabWidget.getTabParent(), source));
}
selectInitialTab();
@@ -213,18 +213,6 @@
mTabWidget.postInvalidate();
}
-
- /**
- * Add a tab to be displayed in the {@link ScrollingTabWidget}.
- *
- * @param contactId The contact id associated with the tab.
- * @param label A label to display in the tab indicator.
- * @param icon An icon to display in the tab indicator.
- */
- protected void addTab(long contactId, String label, Drawable icon) {
- addTab(contactId, createTabIndicatorView(mTabWidget, label, icon));
- }
-
/**
* Add a tab to be displayed in the {@link ScrollingTabWidget}.
*
diff --git a/src/com/android/contacts/ScrollingTabWidget.java b/src/com/android/contacts/ScrollingTabWidget.java
index ddd101b..466071a 100644
--- a/src/com/android/contacts/ScrollingTabWidget.java
+++ b/src/com/android/contacts/ScrollingTabWidget.java
@@ -152,6 +152,14 @@
return mTabsView.getChildCount();
}
+ /**
+ * Returns the {@link ViewGroup} that actually contains the tabs. This is where the tab
+ * views should be attached to when being inflated.
+ */
+ public ViewGroup getTabParent() {
+ return mTabsView;
+ }
+
public void removeAllTabs() {
mTabsView.removeAllViews();
}
diff --git a/src/com/android/contacts/TabStripView.java b/src/com/android/contacts/TabStripView.java
index 70878ea..ae80be0 100644
--- a/src/com/android/contacts/TabStripView.java
+++ b/src/com/android/contacts/TabStripView.java
@@ -25,6 +25,7 @@
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewParent;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
@@ -57,6 +58,16 @@
}
@Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ ViewParent parent = getParent();
+ if (parent instanceof HorizontalScrollView) {
+ setMinimumWidth(((HorizontalScrollView) getParent()).getMeasuredWidth());
+ }
+
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+
+ @Override
public void childDrawableStateChanged(View child) {
if (child == getChildAt(mSelectedTabIndex)) {
// To make sure that the bottom strip is redrawn
diff --git a/src/com/android/contacts/ViewContactActivity.java b/src/com/android/contacts/ViewContactActivity.java
index da49188..cd9802c 100644
--- a/src/com/android/contacts/ViewContactActivity.java
+++ b/src/com/android/contacts/ViewContactActivity.java
@@ -265,7 +265,8 @@
}
private void addAllTab() {
- View allTabIndicator = mInflater.inflate(R.layout.all_tab_indicator, mTabWidget, false);
+ View allTabIndicator = mInflater.inflate(R.layout.all_tab_indicator,
+ mTabWidget.getTabParent(), false);
allTabIndicator.getBackground().setDither(true);
addTab(ALL_CONTACTS_ID, allTabIndicator);
}
diff --git a/src/com/android/contacts/ui/EditContactActivity.java b/src/com/android/contacts/ui/EditContactActivity.java
index 03ef79a..0946e39 100644
--- a/src/com/android/contacts/ui/EditContactActivity.java
+++ b/src/com/android/contacts/ui/EditContactActivity.java
@@ -335,7 +335,8 @@
selectedTab = mTabWidget.getTabCount();
}
- final View tabView = BaseContactCardActivity.createTabIndicatorView(mTabWidget, source);
+ final View tabView = BaseContactCardActivity.createTabIndicatorView(
+ mTabWidget.getTabParent(), source);
mTabWidget.addTab(tabView);
}
if (mState.size() > 0) {