Coil Image
Requests loading an image with a loading placeholder and error image resource (ImageBitmap, ImageVector, Painter).
CoilImage(
imageModel = imageModel,
shimmerParams = ShimmerParams (
baseColor = backgroundColor,
highlightColor = highlightColor
),
error = ImageBitmap.imageResource(R.drawable.error)
)
or we can use ImageVector or custom Painter like the below.
error = ImageVector.vectorResource(R.drawable.error)
Parameters
The data model to request image. See ImageRequest.Builder.data for types allowed.
Modifier used to adjust the layout or drawing content.
The context for creating the ImageRequest.Builder.
The LifecycleOwner for constructing the ImageRequest.Builder.
The ImageLoader to use when requesting the image. Defaults to LocalCoilProvider.getCoilImageLoader.
The alignment parameter used to place the loaded ImageBitmap in the image container.
The alpha parameter used to apply for the image when it is rendered onscreen.
The scale parameter used to determine the aspect ratio scaling to be used for the loaded ImageBitmap.
The content description used to provide accessibility to describe the image.
Whether to run a circular reveal animation when images are successfully loaded.
The duration of the circular reveal animation.
The colorFilter parameter used to apply for the image when it is rendered onscreen.
The shimmer related parameter used to determine constructions of the Shimmer.
A Palette generator for extracting major (theme) colors from images.
An ImageBitmap, ImageVector, or Painter for showing instead of the target image when images are failed to load.
Requests loading an image with a loading placeholder and error image resource (ImageBitmap, ImageVector, Painter).
CoilImage(
imageModel = imageModel,
placeHolder = ImageBitmap.imageResource(R.drawable.placeholder),
error = ImageBitmap.imageResource(R.drawable.error)
)
or we can use ImageVector or custom Painter like the below.
placeHolder = ImageVector.vectorResource(R.drawable.placeholder)
error = ImageVector.vectorResource(R.drawable.error)
Parameters
The data model to request image. See ImageRequest.Builder.data for types allowed.
Modifier used to adjust the layout or drawing content.
The context for creating the ImageRequest.Builder.
The LifecycleOwner for constructing the ImageRequest.Builder.
The ImageLoader to use when requesting the image. Defaults to LocalCoilProvider.getCoilImageLoader.
The alignment parameter used to place the loaded ImageBitmap in the image container.
The alpha parameter used to apply for the image when it is rendered onscreen.
The scale parameter used to determine the aspect ratio scaling to be used for the loaded ImageBitmap.
The content description used to provide accessibility to describe the image.
Whether to run a circular reveal animation when images are successfully loaded.
The duration of the circular reveal animation.
A Palette generator for extracting major (theme) colors from images.
The colorFilter parameter used to apply for the image when it is rendered onscreen.
An ImageBitmap, ImageVector, or Painter to be displayed when the request is in progress.
An ImageBitmap, ImageVector, or Painter for showing instead of the target image when images are failed to load.
Requests loading an image and create some composables based on CoilImageState.
CoilImage(
imageModel = imageModel,
modifier = modifier,
shimmerParams = ShimmerParams (
baseColor = backgroundColor,
highlightColor = highlightColor
),
failure = {
Text(text = "image request failed.")
})
Parameters
The data model to request image. See ImageRequest.Builder.data for types allowed.
Modifier used to adjust the layout or drawing content.
The context for creating the ImageRequest.Builder.
The LifecycleOwner for constructing the ImageRequest.Builder.
The ImageLoader to use when requesting the image. Defaults to LocalCoilProvider.getCoilImageLoader.
The alignment parameter used to place the loaded ImageBitmap in the image container.
The alpha parameter used to apply for the image when it is rendered onscreen.
The scale parameter used to determine the aspect ratio scaling to be used for the loaded ImageBitmap.
The content description used to provide accessibility to describe the image.
Whether to run a circular reveal animation when images are successfully loaded.
The duration of the circular reveal animation.
A Palette generator for extracting major (theme) colors from images.
The colorFilter parameter used to apply for the image when it is rendered onscreen.
Content to be displayed when the request is succeeded.
Content to be displayed when the request is failed.
Requests loading an image and create some composables based on CoilImageState.
CoilImage(
imageModel = imageModel,
modifier = modifier,
loading = {
ConstraintLayout(
modifier = Modifier.fillMaxSize()
) {
val indicator = createRef()
CircularProgressIndicator(
modifier = Modifier.constrainAs(indicator) {
top.linkTo(parent.top)
bottom.linkTo(parent.bottom)
start.linkTo(parent.start)
end.linkTo(parent.end)
}
)
}
},
failure = {
Text(text = "image request failed.")
})
Parameters
The data model to request image. See ImageRequest.Builder.data for types allowed.
Modifier used to adjust the layout or drawing content.
The context for creating the ImageRequest.Builder.
The LifecycleOwner for constructing the ImageRequest.Builder.
The ImageLoader to use when requesting the image. Defaults to LocalCoilProvider.getCoilImageLoader.
The alignment parameter used to place the loaded ImageBitmap in the image container.
The alpha parameter used to apply for the image when it is rendered onscreen.
The scale parameter used to determine the aspect ratio scaling to be used for the loaded ImageBitmap.
The content description used to provide accessibility to describe the image.
Whether to run a circular reveal animation when images are successfully loaded.
The duration of the circular reveal animation.
A Palette generator for extracting major (theme) colors from images.
The colorFilter parameter used to apply for the image when it is rendered onscreen.
Content to be displayed when the request is in progress.
Content to be displayed when the request is succeeded.
Content to be displayed when the request is failed.
Requests loading an image and create some composables based on CoilImageState.
CoilImage(
imageRequest = ImageRequest.Builder(context)
.data(imageModel)
.lifecycle(lifecycleOwner)
.build(),
modifier = modifier,
shimmerParams = ShimmerParams (
baseColor = backgroundColor,
highlightColor = highlightColor
),
failure = {
Text(text = "image request failed.")
})
Parameters
The request to execute.
Modifier used to adjust the layout or drawing content.
The ImageLoader to use when requesting the image. Defaults to LocalCoilProvider.getCoilImageLoader.
The alignment parameter used to place the loaded ImageBitmap in the image container.
The alpha parameter used to apply for the image when it is rendered onscreen.
The scale parameter used to determine the aspect ratio scaling to be used for the loaded ImageBitmap.
The content description used to provide accessibility to describe the image.
Whether to run a circular reveal animation when images are successfully loaded.
The duration of the circular reveal animation.
A Palette generator for extracting major (theme) colors from images.
The colorFilter parameter used to apply for the image when it is rendered onscreen.
Content to be displayed when the request is succeeded.
Content to be displayed when the request is failed.
Requests loading an image and create some composables based on CoilImageState.
CoilImage(
imageRequest = ImageRequest.Builder(context)
.data(imageModel)
.lifecycle(lifecycleOwner)
.build(),
modifier = modifier,
loading = {
ConstraintLayout(
modifier = Modifier.fillMaxSize()
) {
val indicator = createRef()
CircularProgressIndicator(
modifier = Modifier.constrainAs(indicator) {
top.linkTo(parent.top)
bottom.linkTo(parent.bottom)
start.linkTo(parent.start)
end.linkTo(parent.end)
}
)
}
},
failure = {
Text(text = "image request failed.")
})
Parameters
The request to execute.
Modifier used to adjust the layout or drawing content.
The ImageLoader to use when requesting the image. Defaults to LocalCoilProvider.getCoilImageLoader.
The alignment parameter used to place the loaded ImageBitmap in the image container.
The alpha parameter used to apply for the image when it is rendered onscreen.
The scale parameter used to determine the aspect ratio scaling to be used for the loaded ImageBitmap.
The content description used to provide accessibility to describe the image.
Whether to run a circular reveal animation when images are successfully loaded.
The duration of the circular reveal animation.
A Palette generator for extracting major (theme) colors from images.
The colorFilter parameter used to apply for the image when it is rendered onscreen.
Content to be displayed when the request is in progress.
Content to be displayed when the request is succeeded.
Content to be displayed when the request is failed.