Understand modifier placement for shimmer
masterThe order of modifiers is critical. The shimmer() modifier affects only the elements that follow it in the modifier chain.
- Shimmering background: If
.shimmer()is placed before.background(), the background itself will shimmer. - Non-shimmering background: If
.shimmer()is placed after.background(), the background will remain static, and only the content/subsequent modifiers will shimmer.
// The background WILL shimmer
Box(
modifier = Modifier
.size(128.dp)
.shimmer()
.background(Color.Blue)
)
// The background WILL NOT shimmer
Box(
modifier = Modifier
.size(128.dp)
.background(Color.Blue)
.shimmer()
)