Skip to content
🤔 Documentation issue? Report or edit

How to load an image

Info

This is the API of version 1.0.0-alpha12. Newer versions may have a different one

Load Image

You can use painterResource to load an image from the resources

@Composable
fun ImageResourceDemo() {
    val image: Painter = painterResource(id = R.drawable.composelogo)
    Image(painter = image,contentDescription = "")
}
Or load an Icon from Material Icons

@Composable
fun ImageResourceDemo() {
    Icon(Icons.Rounded.Home,contentDescription = "")
}

Remember to add dependencies to build.gradle

    implementation "androidx.compose.material:material-icons-extended:$compose_version"

See also:


Last update: April 9, 2021