-
public class ResourceUtilA Utility for handling the changes in the Android Resources API and the support Drawables to correctly retrieve tinted Drawables
-
-
Method Summary
Modifier and Type Method Description static Drawabletint(Context context, int drawableRes, int colorRes)Retrieves the drawable specified with the drawableResusing thecolorResto correctly tint it before returning the Drawable object.static Drawabletint(Context context, Drawable drawable, int colorRes)Retrieves the drawable specified with the drawableusing thecolorResto correctly tint it before returning the Drawable object.static DrawabletintList(Context context, int drawableRes, int tintListRes)Retrieves the drawable specified with the drawableResusing thetintListResto correctly tint it before returning the Drawable object.static DrawabletintList(Context context, Drawable drawable, int tintListRes)Retrieves the drawable specified with the drawableusing thetintListResto correctly tint it before returning the Drawable object.static DrawablegetDrawable(Context context, int drawableResourceId)Retrieves the drawable specified with the resourceId.static intgetResolvedResourceId(Context context, int attr)Resolves the reference to an attribute, returning the root resource id. static intgetColor(Context context, int colorRes)Retrieves the color specified with the colorRes.static ColorStateListgetColorStateList(Context context, int colorRes)Retrieves the ColorStateList specified with the colorRes.-
-
Method Detail
-
tint
static Drawable tint(Context context, int drawableRes, int colorRes)
Retrieves the drawable specified with the
drawableResusing thecolorResto correctly tint it before returning the Drawable object.- Parameters:
context- The context to use for retrieving the drawabledrawableRes- The resource id for the drawable to retrievecolorRes- The resource id for the color to use for tinting
-
tint
static Drawable tint(Context context, Drawable drawable, int colorRes)
Retrieves the drawable specified with the
drawableusing thecolorResto correctly tint it before returning the Drawable object.- Parameters:
context- The context to use for retrieving the drawabledrawable- The Drawable to tintcolorRes- The resource id for the color to use for tinting
-
tintList
static Drawable tintList(Context context, int drawableRes, int tintListRes)
Retrieves the drawable specified with the
drawableResusing thetintListResto correctly tint it before returning the Drawable object.- Parameters:
context- The context to use for retrieving the drawabledrawableRes- The resource id for the drawable to retrievetintListRes- The resource id for the ColorStateList to use for tinting
-
tintList
static Drawable tintList(Context context, Drawable drawable, int tintListRes)
Retrieves the drawable specified with the
drawableusing thetintListResto correctly tint it before returning the Drawable object.- Parameters:
context- The context to use for retrieving the drawabledrawable- The Drawable to tinttintListRes- The resource id for the ColorStateList to use for tinting
-
getDrawable
static Drawable getDrawable(Context context, int drawableResourceId)
Retrieves the drawable specified with the
resourceId. This is a helper method to deal with the API differences for retrieving drawables- Parameters:
context- The context to use when retrieving the drawabledrawableResourceId- The id for the drawable to retrieve
-
getResolvedResourceId
@AnyRes() static int getResolvedResourceId(Context context, int attr)
Resolves the reference to an attribute, returning the root resource id.
- Parameters:
context- The context to use when determining the root idattr- The attribute to resolve
-
getColor
static int getColor(Context context, int colorRes)
Retrieves the color specified with the
colorRes. This is a helper method to deal with the API differences for retrieving colors.- Parameters:
context- The context to use when retrieving the colorcolorRes- The id for the color to retrieve
-
getColorStateList
static ColorStateList getColorStateList(Context context, int colorRes)
Retrieves the ColorStateList specified with the
colorRes. This is a helper method to deal with the API differences for retrieving colors.- Parameters:
context- The context to use when retrieving the colorcolorRes- The id for the ColorStateList to retrieve
-
-
-
-