Modifier and Type | Method and Description |
---|---|
static int |
getColor(Resources res,
int id,
Resources.Theme theme)
Returns a themed color integer associated with a particular resource ID.
|
static ColorStateList |
getColorStateList(Resources res,
int id,
Resources.Theme theme)
Returns a themed color state list associated with a particular resource
ID.
|
static Drawable |
getDrawable(Resources res,
int id,
Resources.Theme theme)
Return a drawable object associated with a particular resource ID and
styled for the specified theme.
|
static Drawable |
getDrawableForDensity(Resources res,
int id,
int density,
Resources.Theme theme)
Return a drawable object associated with a particular resource ID for
the given screen density in DPI and styled for the specified theme.
|
@Nullable public static Drawable getDrawable(@NonNull Resources res, @DrawableRes int id, @Nullable Resources.Theme theme) throws Resources.NotFoundException
Prior to API level 21, the theme will not be applied and this method
simply calls through to Resources.getDrawable(int)
.
id
- The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.theme
- The theme used to style the drawable attributes, may be
null
.Resources.NotFoundException
- Throws NotFoundException if the given ID does
not exist.@Nullable public static Drawable getDrawableForDensity(@NonNull Resources res, @DrawableRes int id, int density, @Nullable Resources.Theme theme) throws Resources.NotFoundException
Prior to API level 15, the theme and density will not be applied and
this method simply calls through to Resources.getDrawable(int)
.
Prior to API level 21, the theme will not be applied and this method calls through to Resources#getDrawableForDensity(int, int).
id
- The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.density
- The desired screen density indicated by the resource as
found in DisplayMetrics
.theme
- The theme used to style the drawable attributes, may be
null
.Resources.NotFoundException
- Throws NotFoundException if the given ID does
not exist.public static int getColor(@NonNull Resources res, @ColorRes int id, @Nullable Resources.Theme theme) throws Resources.NotFoundException
ColorStateList
, then the default
color from the set is returned.
Prior to API level 23, the theme will not be applied and this method
calls through to Resources.getColor(int)
.
id
- The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.theme
- The theme used to style the color attributes, may be
null
.0xAARRGGBB
.Resources.NotFoundException
- Throws NotFoundException if the given ID does
not exist.@Nullable public static ColorStateList getColorStateList(@NonNull Resources res, @ColorRes int id, @Nullable Resources.Theme theme) throws Resources.NotFoundException
ColorStateList
holding multiple possible colors.
Prior to API level 23, the theme will not be applied and this method
calls through to Resources.getColorStateList(int)
.
id
- The desired resource identifier of a ColorStateList
,
as generated by the aapt tool. This integer encodes the
package, type, and resource entry. The value 0 is an invalid
identifier.theme
- The theme used to style the color attributes, may be
null
.Resources.NotFoundException
- Throws NotFoundException if the given ID does
not exist.