Skip to content
🤔 Documentation issue? Report or edit

How to load an image

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: July 27, 2022