diff options
author | Michael Kolb <kolby@google.com> | 2011-05-18 09:23:04 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-05-18 09:23:04 -0700 |
commit | e755c575712cfee4aa558df7fcd5defe97927f2b (patch) | |
tree | ce22a510b0c9b70b80a3591e1b27dce3a4fd1f9f | |
parent | 1617b123ee4f5468d1b3cf605d84c7dc616b42e1 (diff) | |
parent | 2649380163039804809d38612e490f02dd14f169 (diff) | |
download | packages_apps_Browser-e755c575712cfee4aa558df7fcd5defe97927f2b.zip packages_apps_Browser-e755c575712cfee4aa558df7fcd5defe97927f2b.tar.gz packages_apps_Browser-e755c575712cfee4aa558df7fcd5defe97927f2b.tar.bz2 |
am 26493801: am 5358c83a: Merge "adjust tab width for screen size" into honeycomb-mr2
* commit '2649380163039804809d38612e490f02dd14f169':
adjust tab width for screen size
-rw-r--r-- | res/values-w720dp/dimensions.xml | 19 | ||||
-rw-r--r-- | res/values/dimensions.xml | 4 | ||||
-rw-r--r-- | src/com/android/browser/TabBar.java | 25 | ||||
-rw-r--r-- | src/com/android/browser/TabScrollView.java | 12 |
4 files changed, 53 insertions, 7 deletions
diff --git a/res/values-w720dp/dimensions.xml b/res/values-w720dp/dimensions.xml new file mode 100644 index 0000000..dcb5927 --- /dev/null +++ b/res/values-w720dp/dimensions.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2011 The Android Open Source Project Licensed under the + Apache License, Version 2.0 (the "License"); you may not use this file + except in compliance with the License. You may obtain a copy of the + License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by + applicable law or agreed to in writing, software distributed under the + License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + CONDITIONS OF ANY KIND, either express or implied. See the License for + the specific language governing permissions and limitations under the + License. +--> +<resources + xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- The width of a selected tab --> + <dimen name="tab_width_selected">280dp</dimen> + <!-- The width of an unselected tab --> + <dimen name="tab_width_unselected">240dp</dimen> +</resources> diff --git a/res/values/dimensions.xml b/res/values/dimensions.xml index 28b9e8b..450c580 100644 --- a/res/values/dimensions.xml +++ b/res/values/dimensions.xml @@ -13,9 +13,9 @@ <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <!-- The width of a selected tab --> - <dimen name="tab_width_selected">280dp</dimen> + <dimen name="tab_width_selected">200dp</dimen> <!-- The width of an unselected tab --> - <dimen name="tab_width_unselected">240dp</dimen> + <dimen name="tab_width_unselected">160dp</dimen> <dimen name="tab_height">44dp</dimen> <dimen name="tab_overlap">8dp</dimen> <dimen name="tab_addoverlap">14dp</dimen> diff --git a/src/com/android/browser/TabBar.java b/src/com/android/browser/TabBar.java index a574d26..6c3949a 100644 --- a/src/com/android/browser/TabBar.java +++ b/src/com/android/browser/TabBar.java @@ -24,6 +24,7 @@ import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.app.Activity; import android.content.Context; +import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapShader; @@ -65,8 +66,8 @@ public class TabBar extends LinearLayout private TabControl mTabControl; private XLargeUi mUi; - private final int mTabWidthSelected; - private final int mTabWidthUnselected; + private int mTabWidthSelected; + private int mTabWidthUnselected; private TabScrollView mTabs; @@ -138,6 +139,16 @@ public class TabBar extends LinearLayout mFocusPaint.setColor(res.getColor(R.color.tabFocusHighlight)); } + @Override + public void onConfigurationChanged(Configuration config) { + super.onConfigurationChanged(config); + Resources res = mActivity.getResources(); + mTabWidthSelected = (int) res.getDimension(R.dimen.tab_width_selected); + mTabWidthUnselected = (int) res.getDimension(R.dimen.tab_width_unselected); + // force update of tab bar + mTabs.updateLayout(); + } + void setUseQuickControls(boolean useQuickControls) { mUseQuickControls = useQuickControls; mNewTab.setVisibility(mUseQuickControls ? View.GONE @@ -404,12 +415,16 @@ public class TabBar extends LinearLayout R.style.TabTitleSelected : R.style.TabTitleUnselected); setHorizontalFadingEdgeEnabled(!mSelected); super.setActivated(selected); + updateLayoutParams(); + setFocusable(!selected); + postInvalidate(); + } + + public void updateLayoutParams() { LayoutParams lp = (LinearLayout.LayoutParams) getLayoutParams(); - lp.width = selected ? mTabWidthSelected : mTabWidthUnselected; + lp.width = mSelected ? mTabWidthSelected : mTabWidthUnselected; lp.height = LayoutParams.MATCH_PARENT; setLayoutParams(lp); - setFocusable(!selected); - postInvalidate(); } void setDisplayTitle(String title) { diff --git a/src/com/android/browser/TabScrollView.java b/src/com/android/browser/TabScrollView.java index d0648b7..f43d6d6 100644 --- a/src/com/android/browser/TabScrollView.java +++ b/src/com/android/browser/TabScrollView.java @@ -16,6 +16,8 @@ package com.android.browser; +import com.android.browser.TabBar.TabView; + import android.animation.ObjectAnimator; import android.content.Context; import android.util.AttributeSet; @@ -85,6 +87,16 @@ public class TabScrollView extends HorizontalScrollView { ensureChildVisible(getSelectedTab()); } + // in case of a configuration change, adjust tab width + protected void updateLayout() { + final int count = mContentView.getChildCount(); + for (int i = 0; i < count; i++) { + final TabView tv = (TabView) mContentView.getChildAt(i); + tv.updateLayoutParams(); + } + ensureChildVisible(getSelectedTab()); + } + void setSelectedTab(int position) { View v = getSelectedTab(); if (v != null) { |