say I would like to make the contents of a composa...
# compose
o
say I would like to make the contents of a composable all have an alpha of 0.5 if the
active
flag is false, and 1 if it’s true, is there a nicer way to do it than adding
alpha = if (active) 1f else 0.5f
to each composable inside?
l
Does setting
Modifier.alpha(if (active) 1f else 0.5f)
on the parent works?
o
lol my bad, nevermind i thought something different
yea, nope, that makes the white look …well, out of alpha, I want the elements inside only to have this effect, not the whole row
l
Can you add another layout layer to host the alpha?
o
That's smart
j
CompositionLocalProvider for LocalContentAlpha is probably what you want - see example here