summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2014-07-19 19:21:27 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-07-18 18:24:25 +0000
commitfba286a056985f3e44f4ea587782a67ef60920bd (patch)
tree76eff7eaeff854e36375287f804c81430aa6f95e /core/java
parent335eff4c409571fbb9fa79cdff037b3e62e8de17 (diff)
parenteb97f473fc075c91760c2b657a7014681cd6f3ce (diff)
downloadframeworks_base-fba286a056985f3e44f4ea587782a67ef60920bd.zip
frameworks_base-fba286a056985f3e44f4ea587782a67ef60920bd.tar.gz
frameworks_base-fba286a056985f3e44f4ea587782a67ef60920bd.tar.bz2
Merge "Adapt ActionBar.LayoutParams to Toolbar.LayoutParams on demand" into lmp-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/widget/Toolbar.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/java/android/widget/Toolbar.java b/core/java/android/widget/Toolbar.java
index 712e6d0..c0d8764 100644
--- a/core/java/android/widget/Toolbar.java
+++ b/core/java/android/widget/Toolbar.java
@@ -1006,6 +1006,24 @@ public class Toolbar extends ViewGroup {
super.onRestoreInstanceState(ss.getSuperState());
}
+ /**
+ * @hide
+ */
+ @Override
+ protected void onSetLayoutParams(View child, ViewGroup.LayoutParams lp) {
+ /*
+ * Apps may set ActionBar.LayoutParams on their action bar custom views when
+ * a Toolbar is actually acting in the role of the action bar. Perform a quick
+ * switch with Toolbar.LayoutParams whenever this happens. This does leave open
+ * one potential gotcha: if an app retains the ActionBar.LayoutParams reference
+ * and attempts to keep making changes to it before layout those changes won't
+ * be reflected in the final results.
+ */
+ if (!checkLayoutParams(lp)) {
+ child.setLayoutParams(generateLayoutParams(lp));
+ }
+ }
+
private void measureChildConstrained(View child, int parentWidthSpec, int widthUsed,
int parentHeightSpec, int heightUsed, int heightConstraint) {
final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();