From 81ff1336ddd5b0ec170d6ed841ed5fddac294ddd Mon Sep 17 00:00:00 2001 From: Chris Banes Date: Wed, 30 Nov 2016 01:42:07 +0000 Subject: [PATCH] resolved conflicts for d687245e to master Change-Id: I245e42a399585bd1788db6ba09486ef1c1a6b691 GitOrigin-RevId=c0d908fa15305aa1efe58738c74d54933772186c PiperOrigin-RevId: 140551108 --- api/current.txt | 9 ++ .../widget/CollapsingToolbarLayout.java | 134 +++++++++++++++--- 2 files changed, 123 insertions(+), 20 deletions(-) diff --git a/api/current.txt b/api/current.txt index 8aa5268d5..24a0b1803 100644 --- a/api/current.txt +++ b/api/current.txt @@ -98,6 +98,10 @@ package android.support.design.widget { method public android.graphics.Typeface getCollapsedTitleTypeface(); method public android.graphics.drawable.Drawable getContentScrim(); method public int getExpandedTitleGravity(); + method public int getExpandedTitleMarginBottom(); + method public int getExpandedTitleMarginEnd(); + method public int getExpandedTitleMarginStart(); + method public int getExpandedTitleMarginTop(); method public android.graphics.Typeface getExpandedTitleTypeface(); method public android.graphics.drawable.Drawable getStatusBarScrim(); method public java.lang.CharSequence getTitle(); @@ -111,6 +115,11 @@ package android.support.design.widget { method public void setContentScrimResource(int); method public void setExpandedTitleColor(int); method public void setExpandedTitleGravity(int); + method public void setExpandedTitleMargin(int, int, int, int); + method public void setExpandedTitleMarginBottom(int); + method public void setExpandedTitleMarginEnd(int); + method public void setExpandedTitleMarginStart(int); + method public void setExpandedTitleMarginTop(int); method public void setExpandedTitleTextAppearance(int); method public void setExpandedTitleTypeface(android.graphics.Typeface); method public void setScrimsShown(boolean); diff --git a/src/android/support/design/widget/CollapsingToolbarLayout.java b/src/android/support/design/widget/CollapsingToolbarLayout.java index 26106f9b7..813166341 100644 --- a/src/android/support/design/widget/CollapsingToolbarLayout.java +++ b/src/android/support/design/widget/CollapsingToolbarLayout.java @@ -96,9 +96,9 @@ public class CollapsingToolbarLayout extends FrameLayout { private Toolbar mToolbar; private View mDummyView; - private int mExpandedMarginLeft; + private int mExpandedMarginStart; private int mExpandedMarginTop; - private int mExpandedMarginRight; + private int mExpandedMarginEnd; private int mExpandedMarginBottom; private final Rect mTmpRect = new Rect(); @@ -145,28 +145,16 @@ public class CollapsingToolbarLayout extends FrameLayout { a.getInt(R.styleable.CollapsingToolbarLayout_collapsedTitleGravity, GravityCompat.START | Gravity.CENTER_VERTICAL)); - mExpandedMarginLeft = mExpandedMarginTop = mExpandedMarginRight = mExpandedMarginBottom = + mExpandedMarginStart = mExpandedMarginTop = mExpandedMarginEnd = mExpandedMarginBottom = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMargin, 0); - final boolean isRtl = ViewCompat.getLayoutDirection(this) - == ViewCompat.LAYOUT_DIRECTION_RTL; if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart)) { - final int marginStart = a.getDimensionPixelSize( + mExpandedMarginStart = a.getDimensionPixelSize( R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart, 0); - if (isRtl) { - mExpandedMarginRight = marginStart; - } else { - mExpandedMarginLeft = marginStart; - } } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd)) { - final int marginEnd = a.getDimensionPixelSize( + mExpandedMarginEnd = a.getDimensionPixelSize( R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd, 0); - if (isRtl) { - mExpandedMarginLeft = marginEnd; - } else { - mExpandedMarginRight = marginEnd; - } } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop)) { mExpandedMarginTop = a.getDimensionPixelSize( @@ -197,7 +185,6 @@ public class CollapsingToolbarLayout extends FrameLayout { mCollapsingTextHelper.setCollapsedTextAppearance( a.getResourceId( R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance, 0)); - } setContentScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_contentScrim)); @@ -389,9 +376,9 @@ public class CollapsingToolbarLayout extends FrameLayout { bottom - mToolbar.getTitleMarginBottom()); // Update the expanded bounds mCollapsingTextHelper.setExpandedBounds( - mExpandedMarginLeft, + isRtl ? mExpandedMarginEnd : mExpandedMarginStart, mTmpRect.bottom + mExpandedMarginTop, - right - left - mExpandedMarginRight, + right - left - (isRtl ? mExpandedMarginStart : mExpandedMarginEnd), bottom - top - mExpandedMarginBottom); // Now recalculate using the new bounds mCollapsingTextHelper.recalculate(); @@ -787,6 +774,113 @@ public class CollapsingToolbarLayout extends FrameLayout { return mCollapsingTextHelper.getExpandedTypeface(); } + /** + * Sets the expanded title margins. + * + * @param start the starting title margin in pixels + * @param top the top title margin in pixels + * @param end the ending title margin in pixels + * @param bottom the bottom title margin in pixels + * + * @see #getExpandedTitleMarginStart() + * @see #getExpandedTitleMarginTop() + * @see #getExpandedTitleMarginEnd() + * @see #getExpandedTitleMarginBottom() + * @attr ref android.support.design.R.styleable#CollapsingToolbarLayout_expandedTitleMargin + */ + public void setExpandedTitleMargin(int start, int top, int end, int bottom) { + mExpandedMarginStart = start; + mExpandedMarginTop = top; + mExpandedMarginEnd = end; + mExpandedMarginBottom = bottom; + requestLayout(); + } + + /** + * @return the starting expanded title margin in pixels + * + * @see #setExpandedTitleMarginStart(int) + * @attr ref android.support.design.R.styleable#CollapsingToolbarLayout_expandedTitleMarginStart + */ + public int getExpandedTitleMarginStart() { + return mExpandedMarginStart; + } + + /** + * Sets the starting expanded title margin in pixels. + * + * @param margin the starting title margin in pixels + * @see #getExpandedTitleMarginStart() + * @attr ref android.support.design.R.styleable#CollapsingToolbarLayout_expandedTitleMarginStart + */ + public void setExpandedTitleMarginStart(int margin) { + mExpandedMarginStart = margin; + requestLayout(); + } + + /** + * @return the top expanded title margin in pixels + * @see #setExpandedTitleMarginTop(int) + * @attr ref android.support.design.R.styleable#CollapsingToolbarLayout_expandedTitleMarginTop + */ + public int getExpandedTitleMarginTop() { + return mExpandedMarginTop; + } + + /** + * Sets the top expanded title margin in pixels. + * + * @param margin the top title margin in pixels + * @see #getExpandedTitleMarginTop() + * @attr ref android.support.design.R.styleable#CollapsingToolbarLayout_expandedTitleMarginTop + */ + public void setExpandedTitleMarginTop(int margin) { + mExpandedMarginTop = margin; + requestLayout(); + } + + /** + * @return the ending expanded title margin in pixels + * @see #setExpandedTitleMarginEnd(int) + * @attr ref android.support.design.R.styleable#CollapsingToolbarLayout_expandedTitleMarginEnd + */ + public int getExpandedTitleMarginEnd() { + return mExpandedMarginEnd; + } + + /** + * Sets the ending expanded title margin in pixels. + * + * @param margin the ending title margin in pixels + * @see #getExpandedTitleMarginEnd() + * @attr ref android.support.design.R.styleable#CollapsingToolbarLayout_expandedTitleMarginEnd + */ + public void setExpandedTitleMarginEnd(int margin) { + mExpandedMarginEnd = margin; + requestLayout(); + } + + /** + * @return the bottom expanded title margin in pixels + * @see #setExpandedTitleMarginBottom(int) + * @attr ref android.support.design.R.styleable#CollapsingToolbarLayout_expandedTitleMarginBottom + */ + public int getExpandedTitleMarginBottom() { + return mExpandedMarginBottom; + } + + /** + * Sets the bottom expanded title margin in pixels. + * + * @param margin the bottom title margin in pixels + * @see #getExpandedTitleMarginBottom() + * @attr ref android.support.design.R.styleable#CollapsingToolbarLayout_expandedTitleMarginBottom + */ + public void setExpandedTitleMarginBottom(int margin) { + mExpandedMarginBottom = margin; + requestLayout(); + } + /** * The additional offset used to define when to trigger the scrim visibility change. */