public final class DrawableUtils
extends java.lang.Object
FlexibleUtils,
LayoutUtils| Constructor and Description |
|---|
DrawableUtils() |
| Modifier and Type | Method and Description |
|---|---|
static int |
getColorControlHighlight(android.content.Context context)
Helper method to get the system (or overridden) default
colorControlHighlight. |
static android.graphics.drawable.ColorDrawable |
getColorDrawable(int color)
Generates the
ColorDrawable object from the provided Color. |
static android.graphics.drawable.Drawable |
getDrawableCompat(android.content.Context context,
int drawableRes)
Helper method to get the drawable by its resource.
|
static android.graphics.drawable.Drawable |
getRippleDrawable(android.graphics.drawable.Drawable drawable,
int rippleColor)
Adds a ripple effect to any Drawable background.
|
static android.graphics.drawable.Drawable |
getSelectableBackgroundCompat(int normalColor,
int pressedColor,
int rippleColor)
Helper method to get a custom selectable background with Ripple color, if device has at least Lollipop.
|
static android.graphics.drawable.Drawable |
getSelectableItemBackground(android.content.Context context)
Helper method to get the system (or overridden) default
selectableItemBackground Drawable. |
static void |
setBackgroundCompat(android.view.View view,
android.graphics.drawable.Drawable drawable)
Helper method to set the background to a view, depending on the android version.
|
static void |
setBackgroundCompat(android.view.View view,
int drawableRes)
Helper method to set the background to a view, depending on the android version
|
static void |
setBackgroundCompat(android.view.View view,
int normalColorRes,
int pressedColorRes,
int rippleColorRes)
Ultra compat method to set the background to a view, providing color resource identifiers.
|
public static void setBackgroundCompat(android.view.View view,
android.graphics.drawable.Drawable drawable)
view - the view to apply the drawabledrawable - drawable objectpublic static void setBackgroundCompat(android.view.View view,
int drawableRes)
view - the view to apply the drawabledrawableRes - drawable resource idpublic static void setBackgroundCompat(android.view.View view,
int normalColorRes,
int pressedColorRes,
int rippleColorRes)
Note: If you already have the color in Integer format, please obtain the
Drawable object from getSelectableBackgroundCompat(int, int, int) and set
it into setBackgroundCompat(View, Drawable).
view - the view interested at the backgroundnormalColorRes - the color resource idpressedColorRes - the pressed color resource idrippleColorRes - the ripple color resource idpublic static android.graphics.drawable.Drawable getDrawableCompat(android.content.Context context,
int drawableRes)
context - the contextdrawableRes - drawable resource idpublic static android.graphics.drawable.Drawable getSelectableItemBackground(android.content.Context context)
selectableItemBackground Drawable.
Returns the R.attr.selectableItemBackground of the style attribute.context - the contextpublic static int getColorControlHighlight(android.content.Context context)
colorControlHighlight.
Returns the color of the R.attr.colorControlHighlight of the style attribute.context - the contextpublic static android.graphics.drawable.Drawable getSelectableBackgroundCompat(int normalColor,
int pressedColor,
int rippleColor)
normalColor - the color in normal statepressedColor - the pressed colorrippleColor - the color of the ripplepublic static android.graphics.drawable.Drawable getRippleDrawable(android.graphics.drawable.Drawable drawable,
int rippleColor)
drawable - any background drawablerippleColor - the color of the ripplepublic static android.graphics.drawable.ColorDrawable getColorDrawable(int color)
ColorDrawable object from the provided Color.color - the colorColorDrawable object