Reputation: 113
I'm trying to load some icons from url using Coil. But it never shows on screen.
code:
Image(
painter = rememberAsyncImagePainter(icon),
contentDescription = "condition icon"
)
When I log the icon variable I got the url without problems:
icon: //cdn.weatherapi.com/weather/64x64/night/113.png
But the image doesn't appear on the screen, any help?
Upvotes: 0
Views: 1918
Reputation: 113
I solved this by adding https: before the url. It seems like Coil can't add this by default like it happens in the browser.
Upvotes: 1
Reputation: 3015
CoilImage(
imageModel = imageUrl,
// Crop, Fit, Inside, FillHeight, FillWidth, None
contentScale = ContentScale.Crop,
// shows a placeholder while loading the image.
placeHolder = ImageBitmap.imageResource(R.drawable.placeholder),
// shows an error ImageBitmap when the request failed.
error = ImageBitmap.imageResource(R.drawable.error)
)
This should work as a charm (link)
Upvotes: 1