Jetpack Compose 加载 Drawable
Drawable Painter
A library which provides a way to use Android drawables as Jetpack Compose Painters.
This library attempts to support most Drawable configuration, as well as Animatable drawables, such as AnimatedVectorDrawable.
Usage
@Composable fun DrawDrawable() { val drawable = AppCompatResources.getDrawable(LocalContext.current, R.drawable.rectangle) Image( painter = rememberDrawablePainter(drawable = drawable), contentDescription = "content description", ) }
Download
repositories { mavenCentral() } dependencies { implementation "com.google.accompanist:accompanist-drawablepainter:<version>" }