xref: /aosp_15_r20/external/accompanist/docs/drawablepainter.md (revision fa44fe6ae8e729aa3cfe5c03eedbbf98fb44e2c6)
1*fa44fe6aSInna Palant# Drawable Painter
2*fa44fe6aSInna Palant
3*fa44fe6aSInna Palant[![Maven Central](https://img.shields.io/maven-central/v/com.google.accompanist/accompanist-drawablepainter)](https://search.maven.org/search?q=g:com.google.accompanist)
4*fa44fe6aSInna Palant
5*fa44fe6aSInna PalantA library which provides a way to use Android [drawables](https://developer.android.com/guide/topics/resources/drawable-resource) as Jetpack Compose [Painters](https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/painter/Painter).
6*fa44fe6aSInna Palant
7*fa44fe6aSInna PalantThis library attempts to support most Drawable configuration, as well as [Animatable](https://developer.android.com/reference/android/graphics/drawable/Animatable) drawables, such as [AnimatedVectorDrawable](https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable).
8*fa44fe6aSInna Palant
9*fa44fe6aSInna Palant## Usage
10*fa44fe6aSInna Palant
11*fa44fe6aSInna Palant``` kotlin
12*fa44fe6aSInna Palant@Composable
13*fa44fe6aSInna Palantfun DrawDrawable() {
14*fa44fe6aSInna Palant    val drawable = AppCompatResources.getDrawable(LocalContext.current, R.drawable.rectangle)
15*fa44fe6aSInna Palant
16*fa44fe6aSInna Palant    Image(
17*fa44fe6aSInna Palant        painter = rememberDrawablePainter(drawable = drawable),
18*fa44fe6aSInna Palant        contentDescription = "content description",
19*fa44fe6aSInna Palant    )
20*fa44fe6aSInna Palant}
21*fa44fe6aSInna Palant```
22*fa44fe6aSInna Palant
23*fa44fe6aSInna Palant## Download
24*fa44fe6aSInna Palant
25*fa44fe6aSInna Palant[![Maven Central](https://img.shields.io/maven-central/v/com.google.accompanist/accompanist-drawablepainter)](https://search.maven.org/search?q=g:com.google.accompanist)
26*fa44fe6aSInna Palant
27*fa44fe6aSInna Palant```groovy
28*fa44fe6aSInna Palantrepositories {
29*fa44fe6aSInna Palant    mavenCentral()
30*fa44fe6aSInna Palant}
31*fa44fe6aSInna Palant
32*fa44fe6aSInna Palantdependencies {
33*fa44fe6aSInna Palant    implementation "com.google.accompanist:accompanist-drawablepainter:<version>"
34*fa44fe6aSInna Palant}
35*fa44fe6aSInna Palant```
36*fa44fe6aSInna Palant
37*fa44fe6aSInna PalantSnapshots of the development version are available in [Sonatype's `snapshots` repository][snap]. These are updated on every commit.
38*fa44fe6aSInna Palant
39*fa44fe6aSInna Palant[compose]: https://developer.android.com/jetpack/compose
40*fa44fe6aSInna Palant[snap]: https://oss.sonatype.org/content/repositories/snapshots/com/google/accompanist/accompanist-drawablepainter/
41