diff options
| author | 2015-09-17 14:07:42 +0000 | |
|---|---|---|
| committer | 2015-09-17 14:07:42 +0000 | |
| commit | 7b9bfaf784264903d3c22e45dcbccb8fa93ce25b (patch) | |
| tree | 9361ee70c45a99a8436e4d4b86770eb74cf26927 | |
| parent | 70125f70dc058f0a79485ef473783e1fc6adbfc9 (diff) | |
| parent | 4db9d1b48b49ffc43f1c2d46660ca67a88d673f4 (diff) | |
Merge "Add accessor methods for Toolbar title margins"
| -rw-r--r-- | api/current.txt | 17 | ||||
| -rw-r--r-- | api/system-current.txt | 17 | ||||
| -rw-r--r-- | core/java/android/widget/Toolbar.java | 138 | ||||
| -rw-r--r-- | core/res/res/values/attrs.xml | 16 | ||||
| -rw-r--r-- | core/res/res/values/public.xml | 14 | ||||
| -rw-r--r-- | core/res/res/values/styles.xml | 2 |
6 files changed, 198 insertions, 6 deletions
diff --git a/api/current.txt b/api/current.txt index 7e6f445e6ff4..4f181c9e8c20 100644 --- a/api/current.txt +++ b/api/current.txt @@ -323,6 +323,7 @@ package android { field public static final int buttonBarNeutralButtonStyle = 16843914; // 0x101048a field public static final int buttonBarPositiveButtonStyle = 16843913; // 0x1010489 field public static final int buttonBarStyle = 16843566; // 0x101032e + field public static final int buttonGravity = 16844029; // 0x10104fd field public static final int buttonStyle = 16842824; // 0x1010048 field public static final int buttonStyleInset = 16842826; // 0x101004a field public static final int buttonStyleSmall = 16842825; // 0x1010049 @@ -372,6 +373,7 @@ package android { field public static final int codes = 16843330; // 0x1010242 field public static final int collapseColumns = 16843083; // 0x101014b field public static final int collapseContentDescription = 16843984; // 0x10104d0 + field public static final int collapseIcon = 16844030; // 0x10104fe field public static final int color = 16843173; // 0x10101a5 field public static final int colorAccent = 16843829; // 0x1010435 field public static final int colorActivatedHighlight = 16843664; // 0x1010390 @@ -809,6 +811,7 @@ package android { field public static final int marqueeRepeatLimit = 16843293; // 0x101021d field public static final int matchOrder = 16843855; // 0x101044f field public static final int max = 16843062; // 0x1010136 + field public static final int maxButtonHeight = 16844028; // 0x10104fc field public static final int maxDate = 16843584; // 0x1010340 field public static final int maxEms = 16843095; // 0x1010157 field public static final int maxHeight = 16843040; // 0x1010120 @@ -1284,6 +1287,11 @@ package android { field public static final int tintMode = 16843771; // 0x10103fb field public static final int title = 16843233; // 0x10101e1 field public static final int titleCondensed = 16843234; // 0x10101e2 + field public static final int titleMargin = 16844023; // 0x10104f7 + field public static final int titleMarginBottom = 16844027; // 0x10104fb + field public static final int titleMarginEnd = 16844025; // 0x10104f9 + field public static final int titleMarginStart = 16844024; // 0x10104f8 + field public static final int titleMarginTop = 16844026; // 0x10104fa field public static final int titleTextAppearance = 16843822; // 0x101042e field public static final int titleTextColor = 16844003; // 0x10104e3 field public static final int titleTextStyle = 16843512; // 0x10102f8 @@ -41946,6 +41954,10 @@ package android.widget { method public int getPopupTheme(); method public java.lang.CharSequence getSubtitle(); method public java.lang.CharSequence getTitle(); + method public int getTitleMarginBottom(); + method public int getTitleMarginEnd(); + method public int getTitleMarginStart(); + method public int getTitleMarginTop(); method public boolean hasExpandedActionView(); method public boolean hideOverflowMenu(); method public void inflateMenu(int); @@ -41971,6 +41983,11 @@ package android.widget { method public void setSubtitleTextColor(int); method public void setTitle(int); method public void setTitle(java.lang.CharSequence); + method public void setTitleMargin(int, int, int, int); + method public void setTitleMarginBottom(int); + method public void setTitleMarginEnd(int); + method public void setTitleMarginStart(int); + method public void setTitleMarginTop(int); method public void setTitleTextAppearance(android.content.Context, int); method public void setTitleTextColor(int); method public boolean showOverflowMenu(); diff --git a/api/system-current.txt b/api/system-current.txt index 0a2a5212532f..18fcb31f78e8 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -415,6 +415,7 @@ package android { field public static final int buttonBarNeutralButtonStyle = 16843914; // 0x101048a field public static final int buttonBarPositiveButtonStyle = 16843913; // 0x1010489 field public static final int buttonBarStyle = 16843566; // 0x101032e + field public static final int buttonGravity = 16844029; // 0x10104fd field public static final int buttonStyle = 16842824; // 0x1010048 field public static final int buttonStyleInset = 16842826; // 0x101004a field public static final int buttonStyleSmall = 16842825; // 0x1010049 @@ -464,6 +465,7 @@ package android { field public static final int codes = 16843330; // 0x1010242 field public static final int collapseColumns = 16843083; // 0x101014b field public static final int collapseContentDescription = 16843984; // 0x10104d0 + field public static final int collapseIcon = 16844030; // 0x10104fe field public static final int color = 16843173; // 0x10101a5 field public static final int colorAccent = 16843829; // 0x1010435 field public static final int colorActivatedHighlight = 16843664; // 0x1010390 @@ -901,6 +903,7 @@ package android { field public static final int marqueeRepeatLimit = 16843293; // 0x101021d field public static final int matchOrder = 16843855; // 0x101044f field public static final int max = 16843062; // 0x1010136 + field public static final int maxButtonHeight = 16844028; // 0x10104fc field public static final int maxDate = 16843584; // 0x1010340 field public static final int maxEms = 16843095; // 0x1010157 field public static final int maxHeight = 16843040; // 0x1010120 @@ -1380,6 +1383,11 @@ package android { field public static final int tintMode = 16843771; // 0x10103fb field public static final int title = 16843233; // 0x10101e1 field public static final int titleCondensed = 16843234; // 0x10101e2 + field public static final int titleMargin = 16844023; // 0x10104f7 + field public static final int titleMarginBottom = 16844027; // 0x10104fb + field public static final int titleMarginEnd = 16844025; // 0x10104f9 + field public static final int titleMarginStart = 16844024; // 0x10104f8 + field public static final int titleMarginTop = 16844026; // 0x10104fa field public static final int titleTextAppearance = 16843822; // 0x101042e field public static final int titleTextColor = 16844003; // 0x10104e3 field public static final int titleTextStyle = 16843512; // 0x10102f8 @@ -44554,6 +44562,10 @@ package android.widget { method public int getPopupTheme(); method public java.lang.CharSequence getSubtitle(); method public java.lang.CharSequence getTitle(); + method public int getTitleMarginBottom(); + method public int getTitleMarginEnd(); + method public int getTitleMarginStart(); + method public int getTitleMarginTop(); method public boolean hasExpandedActionView(); method public boolean hideOverflowMenu(); method public void inflateMenu(int); @@ -44579,6 +44591,11 @@ package android.widget { method public void setSubtitleTextColor(int); method public void setTitle(int); method public void setTitle(java.lang.CharSequence); + method public void setTitleMargin(int, int, int, int); + method public void setTitleMarginBottom(int); + method public void setTitleMarginEnd(int); + method public void setTitleMarginStart(int); + method public void setTitleMarginTop(int); method public void setTitleTextAppearance(android.content.Context, int); method public void setTitleTextColor(int); method public boolean showOverflowMenu(); diff --git a/core/java/android/widget/Toolbar.java b/core/java/android/widget/Toolbar.java index 471ea9b0031e..acbf5eb8d699 100644 --- a/core/java/android/widget/Toolbar.java +++ b/core/java/android/widget/Toolbar.java @@ -98,6 +98,32 @@ import java.util.List; * <p>In modern Android UIs developers should lean more on a visually distinct color scheme for * toolbars than on their application icon. The use of application icon plus title as a standard * layout is discouraged on API 21 devices and newer.</p> + * + * @attr ref android.R.styleable#Toolbar_buttonGravity + * @attr ref android.R.styleable#Toolbar_collapseContentDescription + * @attr ref android.R.styleable#Toolbar_collapseIcon + * @attr ref android.R.styleable#Toolbar_contentInsetEnd + * @attr ref android.R.styleable#Toolbar_contentInsetLeft + * @attr ref android.R.styleable#Toolbar_contentInsetRight + * @attr ref android.R.styleable#Toolbar_contentInsetStart + * @attr ref android.R.styleable#Toolbar_gravity + * @attr ref android.R.styleable#Toolbar_logo + * @attr ref android.R.styleable#Toolbar_logoDescription + * @attr ref android.R.styleable#Toolbar_maxButtonHeight + * @attr ref android.R.styleable#Toolbar_navigationContentDescription + * @attr ref android.R.styleable#Toolbar_navigationIcon + * @attr ref android.R.styleable#Toolbar_popupTheme + * @attr ref android.R.styleable#Toolbar_subtitle + * @attr ref android.R.styleable#Toolbar_subtitleTextAppearance + * @attr ref android.R.styleable#Toolbar_subtitleTextColor + * @attr ref android.R.styleable#Toolbar_title + * @attr ref android.R.styleable#Toolbar_titleMargin + * @attr ref android.R.styleable#Toolbar_titleMarginBottom + * @attr ref android.R.styleable#Toolbar_titleMarginEnd + * @attr ref android.R.styleable#Toolbar_titleMarginStart + * @attr ref android.R.styleable#Toolbar_titleMarginTop + * @attr ref android.R.styleable#Toolbar_titleTextAppearance + * @attr ref android.R.styleable#Toolbar_titleTextColor */ public class Toolbar extends ViewGroup { private static final String TAG = "Toolbar"; @@ -203,7 +229,7 @@ public class Toolbar extends ViewGroup { mGravity = a.getInteger(R.styleable.Toolbar_gravity, mGravity); mButtonGravity = a.getInteger(R.styleable.Toolbar_buttonGravity, Gravity.TOP); mTitleMarginStart = mTitleMarginEnd = mTitleMarginTop = mTitleMarginBottom = - a.getDimensionPixelOffset(R.styleable.Toolbar_titleMargins, 0); + a.getDimensionPixelOffset(R.styleable.Toolbar_titleMargin, 0); final int marginStart = a.getDimensionPixelOffset(R.styleable.Toolbar_titleMarginStart, -1); if (marginStart >= 0) { @@ -321,6 +347,116 @@ public class Toolbar extends ViewGroup { return mPopupTheme; } + /** + * Sets the title margin. + * + * @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 #getTitleMarginStart() + * @see #getTitleMarginTop() + * @see #getTitleMarginEnd() + * @see #getTitleMarginBottom() + * @attr ref android.R.styleable#Toolbar_titleMargin + */ + public void setTitleMargin(int start, int top, int end, int bottom) { + mTitleMarginStart = start; + mTitleMarginTop = top; + mTitleMarginEnd = end; + mTitleMarginBottom = bottom; + + requestLayout(); + } + + /** + * @return the starting title margin in pixels + * @see #setTitleMarginStart(int) + * @attr ref android.R.styleable#Toolbar_titleMarginStart + */ + public int getTitleMarginStart() { + return mTitleMarginStart; + } + + /** + * Sets the starting title margin in pixels. + * + * @param margin the starting title margin in pixels + * @see #getTitleMarginStart() + * @attr ref android.R.styleable#Toolbar_titleMarginStart + */ + public void setTitleMarginStart(int margin) { + mTitleMarginStart = margin; + + requestLayout(); + } + + /** + * @return the top title margin in pixels + * @see #setTitleMarginTop(int) + * @attr ref android.R.styleable#Toolbar_titleMarginTop + */ + public int getTitleMarginTop() { + return mTitleMarginTop; + } + + /** + * Sets the top title margin in pixels. + * + * @param margin the top title margin in pixels + * @see #getTitleMarginTop() + * @attr ref android.R.styleable#Toolbar_titleMarginTop + */ + public void setTitleMarginTop(int margin) { + mTitleMarginTop = margin; + + requestLayout(); + } + + /** + * @return the ending title margin in pixels + * @see #setTitleMarginEnd(int) + * @attr ref android.R.styleable#Toolbar_titleMarginEnd + */ + public int getTitleMarginEnd() { + return mTitleMarginEnd; + } + + /** + * Sets the ending title margin in pixels. + * + * @param margin the ending title margin in pixels + * @see #getTitleMarginEnd() + * @attr ref android.R.styleable#Toolbar_titleMarginEnd + */ + public void setTitleMarginEnd(int margin) { + mTitleMarginEnd = margin; + + requestLayout(); + } + + /** + * @return the bottom title margin in pixels + * @see #setTitleMarginBottom(int) + * @attr ref android.R.styleable#Toolbar_titleMarginBottom + */ + public int getTitleMarginBottom() { + return mTitleMarginBottom; + } + + /** + * Sets the bottom title margin in pixels. + * + * @param margin the bottom title margin in pixels + * @see #getTitleMarginBottom() + * @attr ref android.R.styleable#Toolbar_titleMarginBottom + */ + public void setTitleMarginBottom(int margin) { + mTitleMarginBottom = margin; + + requestLayout(); + } + @Override public void onRtlPropertiesChanged(@ResolvedLayoutDir int layoutDirection) { super.onRtlPropertiesChanged(layoutDirection); diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 48bfe28fb89a..902d40dad64f 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -7769,10 +7769,24 @@ i <attr name="title" /> <attr name="subtitle" /> <attr name="gravity" /> - <attr name="titleMargins" format="dimension" /> + <!-- Specifies extra space on the left, start, right and end sides + of the toolbar's title. Margin values should be positive. --> + <attr name="titleMargin" format="dimension" /> + <!-- Specifies extra space on the start side of the toolbar's title. + If both this attribute and titleMargin are specified, then this + attribute takes precedence. Margin values should be positive. --> <attr name="titleMarginStart" format="dimension" /> + <!-- Specifies extra space on the end side of the toolbar's title. + If both this attribute and titleMargin are specified, then this + attribute takes precedence. Margin values should be positive. --> <attr name="titleMarginEnd" format="dimension" /> + <!-- Specifies extra space on the top side of the toolbar's title. + If both this attribute and titleMargin are specified, then this + attribute takes precedence. Margin values should be positive. --> <attr name="titleMarginTop" format="dimension" /> + <!-- Specifies extra space on the bottom side of the toolbar's title. + If both this attribute and titleMargin are specified, then this + attribute takes precedence. Margin values should be positive. --> <attr name="titleMarginBottom" format="dimension" /> <attr name="contentInsetStart" /> <attr name="contentInsetEnd" /> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index a2b6a7bd49a2..b6284c93faab 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -2662,6 +2662,17 @@ <public type="attr" name="listMenuViewStyle" /> <public type="attr" name="subMenuArrow" /> + <public type="attr" name="activityWidth" /> + <public type="attr" name="activityHeight" /> + <public type="attr" name="resizeableActivity" /> + <public type="attr" name="titleMargin" /> + <public type="attr" name="titleMarginStart" /> + <public type="attr" name="titleMarginEnd" /> + <public type="attr" name="titleMarginTop" /> + <public type="attr" name="titleMarginBottom" /> + <public type="attr" name="maxButtonHeight" /> + <public type="attr" name="buttonGravity" /> + <public type="attr" name="collapseIcon" /> <public type="style" name="Theme.Material.DayNight" /> <public type="style" name="Theme.Material.DayNight.DarkActionBar" /> @@ -2682,8 +2693,5 @@ <public type="style" name="Theme.Material.DayNight.DialogWhenLarge.DarkActionBar" /> <public type="id" name="accessibilityActionSetProgress" /> - <public type="attr" name="activityWidth" /> - <public type="attr" name="activityHeight" /> - <public type="attr" name="resizeableActivity" /> </resources> diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index 4bad16d236cd..11c4cc01ee82 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -1232,7 +1232,7 @@ please see styles_device_defaults.xml. <item name="titleTextAppearance">@style/TextAppearance.Widget.Toolbar.Title</item> <item name="subtitleTextAppearance">@style/TextAppearance.Widget.Toolbar.Subtitle</item> <item name="minHeight">?attr/actionBarSize</item> - <item name="titleMargins">4dp</item> + <item name="titleMargin">4dp</item> <item name="maxButtonHeight">56dp</item> <item name="buttonGravity">top</item> <item name="navigationButtonStyle">@style/Widget.Toolbar.Button.Navigation</item> |