ResourcesCompatpublic class ResourcesCompat extends Object Helper for accessing features in {@link android.content.res.Resources}
introduced after API level 4 in a backwards compatible fashion. |
Methods Summary |
---|
public static android.graphics.drawable.Drawable | getDrawable(android.content.res.Resources res, int id, android.content.res.Resources.Theme theme)Return a drawable object associated with a particular resource ID and
styled for the specified theme. Various types of objects will be
returned depending on the underlying resource -- for example, a solid
color, PNG image, scalable image, etc.
Prior to API level 21, the theme will not be applied and this method
simply calls through to {@link Resources#getDrawable(int)}.
final int version = Build.VERSION.SDK_INT;
if (version >= 21) {
return ResourcesCompatApi21.getDrawable(res, id, theme);
} else {
return res.getDrawable(id);
}
| public static android.graphics.drawable.Drawable | getDrawableForDensity(android.content.res.Resources res, int id, int density, android.content.res.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.
Prior to API level 15, the theme and density will not be applied and
this method simply calls through to {@link Resources#getDrawable(int)}.
Prior to API level 21, the theme will not be applied and this method
calls through to Resources.getDrawableForDensity(int, int).
final int version = Build.VERSION.SDK_INT;
if (version >= 21) {
return ResourcesCompatApi21.getDrawableForDensity(res, id, density, theme);
} else if (version >= 15) {
return ResourcesCompatIcsMr1.getDrawableForDensity(res, id, density);
} else {
return res.getDrawable(id);
}
|
|