import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
@Composable
fun SimpleImageScreen() {
Surface(modifier = Modifier.fillMaxSize()) {
Column(
modifier = Modifier.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
painter = painterResource(id = R.drawable.cat_image),
contentDescription = "Cat image"
)
Text(
text = "This is a cat.",
style = MaterialTheme.typography.bodyLarge,
modifier = Modifier.padding(top = 8.dp)
)
}
}
}We use the Image composable to show the picture from drawable resources. The painterResource function loads the image by its resource ID R.drawable.cat_image. We add a contentDescription for accessibility so screen readers can describe the image. Below the image, a Text composable shows a simple description. The Column centers both horizontally and adds padding around the content for nice spacing.