Mohammed Hashim
08/20/2026, 3:08 AMmdpi, hdpi, xhdpi, xxhdpi, etc.) for raster assets.
For example, I currently have a single WebP in res/drawable/ and render it like this:
Box(
modifier = Modifier
.fillMaxSize()
.paint(
painter = painterResource(R.drawable.my_background_image),
contentScale = ContentScale.FillBounds
),
contentAlignment = Alignment.Center
) {
Text(
text = "Hello over background!",
color = Color.White,
fontSize = 24.sp
)
}
I’m not seeing any noticeable performance issues on the devices I have available.
So my question is: for a full-layout background image like this, is there any performance or rendering benefit to providing density-specific WebP assets on Compose Image?
Would appreciate any insights from people who have dealt with this in production.romainguy
08/20/2026, 4:04 AMromainguy
08/20/2026, 4:04 AMromainguy
08/20/2026, 4:06 AMromainguy
08/20/2026, 4:06 AMdrawable/. That's the equivalent of -mdpi which means the asset will be scaled up on high density display. You don't want that because it won't look good (upscaling has to make up information), or it will make your asset use way too much memoryromainguy
08/20/2026, 4:07 AMdrawable-anydpi/ makes more sense if you don't want the asset to be resized, otherwhise put it in whatever dpi buckets that matches the actual density of the asset.Mohammed Hashim
08/21/2026, 2:25 AMMohammed Hashim
08/21/2026, 2:25 AMMohammed Hashim
08/21/2026, 2:30 AMMohammed Hashim
08/21/2026, 2:31 AMdrawable-sw600dp/, drawable-sw720dp/, etc.?romainguy
08/21/2026, 2:33 AMMohammed Hashim
08/21/2026, 2:35 AM