- For a static background, use
Modifier.paintwithContentScale.CropandsizeToIntrinsics = false. In aBox, give the imagematchParentSize(). - Draw the image edge to edge and pad only the content with
safeDrawingPadding(). - A bitmap in plain
drawable/is scaled up on dense screens. Put large backgrounds indrawable-nodpi. Scaffoldpaints an opaque color over your image. SetcontainerColor = Color.Transparent.
Compose has no backgroundImage modifier. You put a picture behind a screen in one of two ways: an Image at the bottom of a Box, or Modifier.paint on the container itself. This guide shows both. Then it covers what decides whether the result looks right on every Android phone: edge-to-edge insets, ContentScale, density folders, memory, Scaffold, tiling and dark mode.
The checks are the same whether your own team builds the screens or you hire Android app developers for the job. Every background has a pixel size, a memory cost and a contrast problem, and you can measure all three before release.
If you have read our guides to background images in Flutter or SwiftUI, the budgets will look familiar. Only the APIs change.
Should you use a Box or Modifier.paint?
Use Modifier.paint for a static background that never changes. Use a Box with an Image when the background needs its own modifiers, such as blur, a crossfade or a parallax offset.
| Need | Modifier.paint | Box + Image |
|---|---|---|
| Who decides the size | The container, if sizeToIntrinsics = false | The content, if the image uses matchParentSize() |
| Static full-screen or card background | Yes, one line | Works, a few more lines |
| Tint or color filter | colorFilter parameter | colorFilter on the Image |
| Blur, crossfade, parallax | Awkward | Easy, the image is its own node |
| Remote image (Coil) | rememberAsyncImagePainter | AsyncImage |
In a Box, give the image Modifier.matchParentSize(), not fillMaxSize(). A Box takes the size of its largest child. An Image with fillMaxSize() inside a Box that wraps its content can push the box to the full screen, and a card that should be 120 dp tall becomes as tall as the phone. matchParentSize() is measured after the other children, so the text decides the size and the image only fills it.
How do you set a background with Modifier.paint?
Add Modifier.paint to the root container with a painter, ContentScale.Crop and sizeToIntrinsics = false:
Column(
modifier = Modifier
.fillMaxSize()
.paint(
painter = painterResource(R.drawable.bg_brushed_metal),
sizeToIntrinsics = false,
contentScale = ContentScale.Crop
)
) {
Text("Welcome")
}Three details catch people out:
- Turn off
sizeToIntrinsics. It istrueby default. Then the painter's pixel size feeds into layout, and a large image can make the container larger than you meant. - Put the modifier after the size.
fillMaxSize()comes first, so the painter has a full-screen area to cover. - Use lowercase resource names. Android accepts only
a-z,0-9and underscores in drawable names.bg-kraft.webpfails the build;bg_kraft.webpworks.
How do you make the image fill the whole screen?
Draw the background edge to edge and pad only the content. Since Android 15, apps that target API 35 are edge to edge by default: the window runs under the status bar and the navigation bar. On older versions, call enableEdgeToEdge() in your activity before setContent.
Then split the work between two layers:
Box(modifier = Modifier.fillMaxSize()) {
Image(
painter = painterResource(R.drawable.bg_brushed_metal),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier.matchParentSize()
)
Column(modifier = Modifier.safeDrawingPadding()) {
Text("Welcome")
}
}This is also the Box version of a background. The image comes first, so it draws first and sits under everything else, and contentDescription = null tells TalkBack to skip it as decorative. The image ignores the insets and fills the window. The column uses safeDrawingPadding(), so text stays clear of the camera cutout, the system bars and the keyboard. If you pad the outer Box instead, the background stops short of the bars and leaves a strip of window color. The edge-to-edge setup guide lists which inset types to use where.
Stop the jump when the keyboard opens
On a login screen the keyboard shrinks the content area. If the image is sized by the same padded container, it rescales every time the keyboard opens. Keep the image in the unpadded layer, as above, and only the content moves. ContentScale.Crop on a full-window image does not change when the keyboard appears.
Which ContentScale should a background use?
Use ContentScale.Crop for almost every full-screen background. It keeps the aspect ratio, fills the bounds and crops what overflows. The default for Image is ContentScale.Fit, which leaves empty bands, so set it explicitly.
| ContentScale | What it does | Use it for |
|---|---|---|
Crop | Fills the bounds, keeps the ratio, crops the rest | Full-screen and card backgrounds |
Fit (default) | Shows the whole image, leaves empty bands | Artwork that must not be cropped |
FillBounds | Stretches width and height separately | Flat colors and soft gradients only |
FillWidth / FillHeight | Matches one side, may crop or band the other | Headers with a fixed height |
None | Natural size, centered | Small marks, rarely backgrounds |
Plan for the portrait crop
Most Android phones are around 9:20 in portrait. A 4:3 file, such as our 1600×1200 backgrounds, loses most of its left and right sides. Keep the key area near the center, or move the crop with alignment = Alignment.TopCenter when the subject sits at the top. On tablets and unfolded foldables the screen is close to square, so the same image shows much more of its width. Calm surfaces with no focal point, like the brushed metal texture, look right on both.
How big should the image be?
Make the file as large as the biggest screen you support, in physical pixels, and put it where Android will not scale it. The size on disk is not the real cost. A decoded bitmap in the default ARGB_8888 format takes 4 bytes per pixel, whatever the file format.
| Image | Pixels | Decoded in memory |
|---|---|---|
| 1080×2400 phone screen | 2.6 million | about 10.4 MB |
| 1440×3120 phone screen | 4.5 million | about 18 MB |
Web Backgrounds file, in drawable-nodpi | 1600×1200 | about 7.7 MB |
Same file in plain drawable/ on a 3x phone | 4800×3600 | about 69 MB |
Mind the density folders
The last row is the classic Android mistake. A bitmap in plain drawable/ is treated as mdpi, the 1x baseline. On an xxhdpi phone, the resource loader scales it up three times in each direction before it reaches your composable, and one background takes the memory of nine. Pick one of two fixes:
- One file: put it in
drawable-nodpi/. Android loads it at its real size andContentScale.Cropdoes the rest. - Several files: export sized copies to
drawable-xhdpi,drawable-xxhdpianddrawable-xxxhdpi. Each device gets only the copy it needs when the app ships as an App Bundle.
The screen density guide lists the scale factor of every bucket. Convert PNG and JPEG backgrounds to WebP before you add them. Android Studio does it from the context menu. Google's WebP documentation puts lossy WebP at 25 to 34 percent smaller than a comparable JPEG.
How do you keep text readable on top?
Darken the image under the text. One extra modifier is enough:
Image(
painter = painterResource(R.drawable.bg_brushed_metal),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier
.matchParentSize()
.drawWithContent {
drawContent()
drawRect(Color.Black.copy(alpha = 0.45f))
}
)A black layer at 40 to 55 percent is a common start for white text on a busy texture. When the text sits only at the bottom, draw a Brush.verticalGradient from transparent to black instead, so the rest of the image stays bright. Modifier.blur softens a busy photo, but it works only on Android 12 and later and is ignored on older versions, so never rely on blur alone for contrast.
The target is the WCAG contrast minimum: 4.5:1 for body text and 3:1 for large text. Measure it on the brightest area that can sit behind text. Our article on readable text on background images shows how.
Why is the background hidden behind a Scaffold?
Scaffold paints its own containerColor, which defaults to the opaque background color of your Material theme. Anything you draw behind it is covered. Make the scaffold transparent and draw the image outside it:
Box(modifier = Modifier.fillMaxSize()) {
Image(
painter = painterResource(R.drawable.bg_dark_slate),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier.matchParentSize()
)
Scaffold(containerColor = Color.Transparent) { innerPadding ->
LazyColumn(contentPadding = innerPadding) { /* rows */ }
}
}A LazyColumn has no background of its own, but Card and Surface rows do. Give them a translucent container color if the texture should show through. A TopAppBar also paints a solid color; pass TopAppBarDefaults.topAppBarColors(containerColor = Color.Transparent) if the bar should float over the image.
How do you tile a small texture?
Use a ShaderBrush with an ImageShader and repeat it on both axes. It replaces the old XML android:tileMode attribute:
val tile = ImageBitmap.imageResource(R.drawable.tile_linen)
val brush = remember(tile) {
ShaderBrush(ImageShader(tile, TileMode.Repeated, TileMode.Repeated))
}
Box(modifier = Modifier.fillMaxSize().background(brush))The shader repeats the bitmap at its decoded pixel size, not in dp. A 512-pixel tile in drawable-nodpi repeats every 512 physical pixels, which is about 170 dp on a 3x phone. Wrap the brush in remember so it is not rebuilt on every recomposition. Edges that do not match show as a grid, so check the tile first with our guide to seamless tileable textures. The Brush documentation shows the other tile modes and the gradient brushes, which need no image file at all.
How do you switch backgrounds for dark mode?
Let resource qualifiers do it. Put the dark file under the same name in drawable-night-nodpi/. painterResource(R.drawable.bg_paper) then loads the right file and switches when the user changes the system theme. No code is needed.
If the app has its own theme switch, read the app's setting or isSystemInDarkTheme() and pick the resource in code. In both cases, a dark variant is not the light file with the brightness turned down. Lower the contrast inside the texture, remove pure white highlights and keep the tone near your dark surface color. Our notes on using backgrounds in dark mode cover the visual side, and the dark slate stone texture is a ready dark base.
Should backgrounds be bundled or loaded from a URL?
Bundle the backgrounds that appear on first launch and on core screens. They work offline and are ready on the first frame.
Load from a URL when backgrounds change often, such as seasonal themes from a CMS. Then:
- Use Coil's
AsyncImagewithContentScale.Crop, and pass aColorPainterin the background's darkest tone as the placeholder. It avoids a white flash. - Let Coil size the request from the layout. It decodes to the size of the composable, so a 4000-pixel original does not land in memory at full size.
- Serve a file sized for phones anyway. The download still costs data.
- Keep Coil's memory and disk caches on, so a background shared by several screens is not fetched and decoded again.
What about the splash screen?
Keep the splash plain and show the rich background on the first real screen. Since Android 12 every app gets a system splash screen: an icon centered on a solid color. You can set the color and the icon through the SplashScreen API, but you cannot put a full-bleed image there. A pattern that works:
- Splash:
windowSplashScreenBackgroundset to the darkest tone of your background. - First screen: the same color as the window background under the image, so the image appears without a flash.
- Onboarding: one background per step at most, all from the same family of textures.
Our guide to splash screen backgrounds covers this hand-off in more detail.
A checklist before you ship
- Static backgrounds use
Modifier.paintwithsizeToIntrinsics = false, or anImagewithmatchParentSize()inside aBox. ContentScale.Cropis set explicitly, not left at theFitdefault.- The image draws edge to edge, and only the content uses inset padding.
- The key area of the image survives a portrait crop and a square tablet screen.
- Large bitmaps live in
drawable-nodpior in sized density folders, never in plaindrawable/. - Text on top reaches 4.5:1 contrast on the brightest part of the image.
- The image has
contentDescription = null. Scaffoldand app bars are transparent where the image should show.- Dark mode loads its own file from a
-nightfolder, not a dimmed copy. - The splash color matches the first screen.
Need a starting point? Browse background textures for calm surfaces that work behind text, or read background images in React Native if part of your app is cross-platform.



