Hello everyone,
I’m working on a Jetpack Compose project where I need to load SVG images from URLs and display them with size constraints. We are using Coil (version 2.4.0) for image loading. The requirement is to allow SVG images to be displayed up to a maximum size of 16.dp x 16.dp, but to use their original size if it’s smaller than the maximum.
I’ve encountered an issue where SVG images loaded from URLs always appear at the maximum size (16.dp x 16.dp), regardless of their original dimensions. For example, an SVG image that is intrinsically 8.dp x 8.dp is also being displayed as 16.dp x 16.dp. Interestingly, when these SVGs are loaded from drawable resources instead of URLs, they respect their original sizes correctly.
Is there a known method or best practice for handling SVG images loaded from URLs in Jetpack Compose with Coil, such that the images are displayed at their original size, but constrained to a maximum size when necessary?
Any insights or suggestions would be greatly appreciated!