public static final class MenuTintHelper.Builder
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private boolean |
forceIcons |
private android.view.Menu |
menu |
private java.lang.Integer |
menuItemIconAlpha |
private java.lang.Integer |
menuItemIconColor |
private java.lang.Integer |
originalMenuItemIconColor |
private java.lang.Integer |
overflowDrawableId |
private boolean |
reApplyOnChange |
private java.lang.Integer |
subMenuIconAlpha |
private java.lang.Integer |
subMenuIconColor |
Modifier | Constructor and Description |
---|---|
private |
Builder(android.view.Menu menu) |
Modifier and Type | Method and Description |
---|---|
MenuTintHelper |
apply(android.app.Activity activity)
Sets a ColorFilter and/or alpha on all the MenuItems in the menu,
including the OverflowMenuButton.
|
MenuTintHelper |
create()
Creates a
MenuTintHelper with the arguments supplied to this
builder. |
MenuTintHelper.Builder |
forceIcons()
Set the menu to show MenuItem icons in the overflow window.
|
MenuTintHelper.Builder |
reapplyOnChange(boolean reapply)
Sets an
MenuItem.OnActionExpandListener on all MenuItem s with
views, so when the menu is updated, the colors will be also. |
MenuTintHelper.Builder |
setMenuItemIconAlpha(int alpha)
Specify an alpha value for visible MenuItem icons, including the
OverflowMenuButton.
|
MenuTintHelper.Builder |
setMenuItemIconColor(int color)
Specify a color for visible MenuItem icons, including the
OverflowMenuButton.
|
MenuTintHelper.Builder |
setOriginalMenuItemIconColor(int color)
Specify a color that is applied when an action view is expanded or
collapsed.
|
MenuTintHelper.Builder |
setOverflowDrawableId(int drawableId)
Set the drawable id to set on the OverflowMenuButton.
|
MenuTintHelper.Builder |
setSubMenuIconAlpha(int alpha)
Specify an alpha value for MenuItems that are in a SubMenu or in the
Overflow menu.
|
MenuTintHelper.Builder |
setSubMenuIconColor(int color)
Specify a color for MenuItems that are in a SubMenu or in the Overflow
menu.
|
private final android.view.Menu menu
private java.lang.Integer menuItemIconColor
private java.lang.Integer menuItemIconAlpha
private java.lang.Integer subMenuIconColor
private java.lang.Integer subMenuIconAlpha
private java.lang.Integer overflowDrawableId
private java.lang.Integer originalMenuItemIconColor
private boolean reApplyOnChange
private boolean forceIcons
public MenuTintHelper.Builder reapplyOnChange(boolean reapply)
Sets an MenuItem.OnActionExpandListener
on all MenuItem
s with
views, so when the menu is updated, the colors will be also.
This is useful when the overflow menu is showing icons and MenuItem
s might be pushed to the overflow menu when a action view is
expanded e.g. android.widget.SearchView.
reapply
- true
to set the listeners on all MenuItem
s
with action views.public MenuTintHelper.Builder setMenuItemIconAlpha(int alpha)
alpha
- the alpha value for the drawable. 0 means fully transparent,
and 255 means fully opaque.public MenuTintHelper.Builder setMenuItemIconColor(int color)
color
- the color to apply on visible MenuItem icons, including the
OverflowMenuButton.public MenuTintHelper.Builder setOriginalMenuItemIconColor(int color)
color
- the color to apply on MenuItems when an action-view is
expanded or collapsed.public MenuTintHelper.Builder setOverflowDrawableId(int drawableId)
drawableId
- the resource identifier of the drawablepublic MenuTintHelper.Builder setSubMenuIconAlpha(int alpha)
alpha
- the alpha value for the drawable. 0 means fully transparent,
and 255 means fully opaque.public MenuTintHelper.Builder setSubMenuIconColor(int color)
color
- the color to apply on visible MenuItem icons, including the
OverflowMenuButton.public MenuTintHelper.Builder forceIcons()
public MenuTintHelper apply(android.app.Activity activity)
Sets a ColorFilter and/or alpha on all the MenuItems in the menu, including the OverflowMenuButton.
Call this method after inflating/creating your menu in
Activity.onCreateOptionsMenu(Menu)
.
Note: This is targeted for the native ActionBar/Toolbar, not AppCompat.
public MenuTintHelper create()
Creates a MenuTintHelper
with the arguments supplied to this
builder.
It does not apply the theme. Call MenuTintHelper.apply(Activity)
to do so.
apply(Activity)