Composable Function

RemoteImage

Creates an image component that lays out and draws a given RemoteImageBitmap.

RemoteImageSample

@Sampled
@Preview
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun RemoteImageSample() {
    val remoteBitmap = remember {
        val imageBitmap = ImageBitmap(120, 60)
        Canvas(imageBitmap).apply {
            drawRect(0f, 0f, 120f, 60f, Paint().apply { color = Color(0xFF1E88E5) })
            drawCircle(Offset(60f, 30f), 20f, Paint().apply { color = Color(0xFFFFCA28) })
        }
        RemoteImageBitmap(imageBitmap)
    }
    RemoteImage(
        bitmap = remoteBitmap,
        contentDescription = "Sample Remote Image".rs,
        modifier = RemoteModifier.size(100.rdp),
        contentScale = RemoteContentScale.Crop,
    )
}

RemoteImageFitSample

@Sampled
@Preview
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun RemoteImageFitSample() {
    val remoteBitmap = remember {
        val imageBitmap = ImageBitmap(120, 60)
        Canvas(imageBitmap).apply {
            drawRect(0f, 0f, 120f, 60f, Paint().apply { color = Color(0xFF1E88E5) })
            drawCircle(Offset(60f, 30f), 20f, Paint().apply { color = Color(0xFFFFCA28) })
        }
        RemoteImageBitmap(imageBitmap)
    }
    RemoteImage(
        bitmap = remoteBitmap,
        contentDescription = "Fit Sample".rs,
        modifier = RemoteModifier.size(100.rdp).background(Color.LightGray.rc),
        contentScale = RemoteContentScale.Fit,
    )
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: