Compose Playground

Image

A composable that lays out and draws a given image asset.

Properties
Preview
Preview
Generated Code
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp

@Composable
fun MyImage() {
    Box(modifier = Modifier.size(192.dp)) {
        Image(
            painter = painterResource(id = R.drawable.my_image),
            contentDescription = "My image description",
            contentScale = ContentScale.Crop
        )
    }
}