Android.Content.Res.Resources.GetDrawable Method
Return a drawable object associated with a particular resource ID.

Syntax

[Android.Runtime.Register("getDrawable", "(I)Landroid/graphics/drawable/Drawable;", "GetGetDrawable_IHandler")]
public virtual Android.Graphics.Drawables.Drawable GetDrawable (int id)

See Also

Resources.GetDrawable(int, .Theme)

Parameters

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.

Returns

Documentation for this section has not yet been entered.

Exceptions

TypeReason
!:NoType:android/content/res/Resources$NotFoundException;Href=../../../../reference/android/content/res/Resources.NotFoundException.htmlThrows NotFoundException if the given ID does not exist.

Remarks

Return a drawable object associated with a particular resource ID. Various types of objects will be returned depending on the underlying resource -- for example, a solid color, PNG image, scalable image, etc. The Drawable API hides these implementation details.

Note: Prior to NoType:android/os/Build$VERSION_CODES;Href=../../../../reference/android/os/Build.VERSION_CODES.html#JELLY_BEAN, this function would not correctly retrieve the final configuration density when the resource ID passed here is an alias to another Drawable resource. This means that if the density configuration of the alias resource is different than the actual resource, the density of the returned Drawable would be incorrect, resulting in bad scaling. To work around this, you can instead retrieve the Drawable through TypedArray.GetDrawable(int). Use Android.Content.Context.ObtainStyledAttributes(Int32[]) with an array containing the resource ID of interest to create the TypedArray.

Note: To obtain a themed drawable, use Android.Content.Context.GetDrawable(int) or Resources.GetDrawable(int, .Theme) passing the desired theme.

[Android Documentation]

Requirements

Namespace: Android.Content.Res
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1