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

Maven Central

repositories {
    mavenCentral()
}

dependencies {
    implementation "com.google.accompanist:accompanist-drawablepainter:<version>"
}

 

posted @ 2022-12-31 19:47  letleon  阅读(112)  评论(0编辑  收藏  举报