androidandroid-jetpack-composeandroid-compose-image

How to load image from assets in Jetpack Compose


I have hundreds of png files in assets folder and I want to load them into Image composable. But what I can use only images in drawable folder. how to load images from assets into Image?


Solution

  • @Halifax solution works but I have some performance issue with it. by using Coil it is much smoother and cleaner.

    in build.gradle (:app) :

    implementation("io.coil-kt:coil-compose:2.2.2")
    

    and then:

    AsyncImage(
                model = "file:///android_asset/images_folder/image.png",
                contentDescription = "",
            )