Return a drawable object associated with a particular resource ID.
This method supports inflation of <vector> and <animated-vector>
resources on devices where platform support is not available.
Parameters
context
Context: context to inflate against
resId
int: 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.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# AppCompatResources\n\nadded in [version 24.1.0](/topic/libraries/support-library/revisions) \nbelongs to Maven artifact com.android.support:appcompat-v7:28.0.0-alpha1 \nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \\| [\\[Expand All\\]](#) \n\nAppCompatResources\n==================\n\n| This package is part of the Android [support library](/topic/libraries/support-library) which is no longer maintained. The support library has been superseded by [AndroidX](/jetpack/androidx) which is part of [Jetpack](/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider [migrating](/jetpack/androidx/migrate) existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library [class\n| mappings](/jetpack/androidx/migrate/class-mappings).\n\n\n`\npublic\n\nfinal\n\nclass\nAppCompatResources\n`\n\n\n`\n\nextends Object\n\n\n`\n\n`\n\n\n`\n\n|---|---------------------------------------------------|\n| java.lang.Object ||\n| ↳ | android.support.v7.content.res.AppCompatResources |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nClass for accessing an application's resources through AppCompat, and thus any backward\ncompatible functionality.\n\nSummary\n-------\n\n| ### Public methods ||\n|-------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` static `[ColorStateList](https://developer.android.com/reference/android/content/res/ColorStateList.html) | ` `[getColorStateList](/reference/android/support/v7/content/res/AppCompatResources#getColorStateList(android.content.Context, int))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, int resId) ` Returns the [ColorStateList](https://developer.android.com/reference/android/content/res/ColorStateList.html) from the given resource. |\n| ` static `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html) | ` `[getDrawable](/reference/android/support/v7/content/res/AppCompatResources#getDrawable(android.content.Context, int))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, int resId) ` Return a drawable object associated with a particular resource ID. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` java.lang.Object ` |-------------------|-------------------------------| | ` Object` | ` clone() ` | | ` boolean` | ` equals(Object arg0) ` | | ` void` | ` finalize() ` | | ` final Class\u003c?\u003e` | ` getClass() ` | | ` int` | ` hashCode() ` | | ` final void` | ` notify() ` | | ` final void` | ` notifyAll() ` | | ` String` | ` toString() ` | | ` final void` | ` wait(long arg0, int arg1) ` | | ` final void` | ` wait(long arg0) ` | | ` final void` | ` wait() ` | ||\n\nPublic methods\n--------------\n\n### getColorStateList\n\nadded in [version 24.1.0](/topic/libraries/support-library/revisions) \n\n```\nColorStateList getColorStateList (Context context, \n int resId)\n```\n\nReturns the [ColorStateList](https://developer.android.com/reference/android/content/res/ColorStateList.html) from the given resource. The resource can include\nthemeable attributes, regardless of API level.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------|-------------------------------------------------------------------------|\n| `context` | `Context`: context to inflate against \u003cbr /\u003e |\n| `resId` | `int`: the resource identifier of the ColorStateList to retrieve \u003cbr /\u003e |\n\n| Returns ||\n|---------------------------------------------------------------------------------------------------|--------|\n| [ColorStateList](https://developer.android.com/reference/android/content/res/ColorStateList.html) | \u003cbr /\u003e |\n\n### getDrawable\n\nadded in [version 25.1.0](/topic/libraries/support-library/revisions) \n\n```\nDrawable getDrawable (Context context, \n int resId)\n```\n\nReturn a drawable object associated with a particular resource ID.\n\nThis method supports inflation of `\u003cvector\u003e` and `\u003canimated-vector\u003e`\nresources on devices where platform support is not available.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `context` | `Context`: context to inflate against \u003cbr /\u003e |\n| `resId` | `int`: 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. \u003cbr /\u003e |\n\n| Returns ||\n|---------------------------------------------------------------------------------------------|-------------------------------------------------------------------|\n| [Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html) | Drawable An object that can be used to draw this resource. \u003cbr /\u003e |\n\n**See also:**\n\n- [getDrawable(Context, int)](/reference/android/support/v4/content/ContextCompat#getDrawable(android.content.Context, int)) \n-\n\n Classes\n -------\n\n - [AppCompatResources](/reference/android/support/v7/content/res/AppCompatResources)"]]