painterResource
Source set: Android
@Composable
public fun painterResource(@DrawableRes id: Int): Painter
Create a Painter from an Android resource id. This can load either an instance of BitmapPainter or VectorPainter for ImageBitmap based assets or vector based assets respectively. The resources with the given id must point to either fully rasterized images (ex. PNG or JPG files) or VectorDrawable xml assets. API based xml Drawables are not supported here.
Example:
Alternative Drawable implementations can be used with compose by calling drawIntoCanvas and drawing with the Android framework canvas provided through nativeCanvas
Example:
Parameters
| id | Resources object to query the image file from |
Return
Painter used for drawing the loaded resource