masteramyx
10/31/2023, 7:13 PMCompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f)) {
Icon(…)
}
Using CompositionLocalProvider like this works fine with simple composables but having a row with image, colored text fields, etc does not give it a proper disabled emphasis.
Are we forced to handle each child composable in the row separately?Chris Fillmore
10/31/2023, 8:07 PMKirill Grouchnikov
10/31/2023, 8:25 PMmasteramyx
11/01/2023, 3:59 PMThe question is what do you want to achieve. Disabled look?Exactly, I’m not concerned with disabling any interaction for this use case, just a uniform greyscale look across the entire composable.
You can apply a graphics layer to the whole thing to set alpha of let’s say 38%. That’s not necessarily what you would want, if your target look is greyscale like in Material.^ Isn’t that what the codeblock in my original message does? I agree, the outcome is not desirable for a more view with more than a few textfields.
Kirill Grouchnikov
11/01/2023, 4:00 PMLocalContentColor
) but depending on the content in that row, you will need to update more than that, since different composables - be they Material composable, or your own - are going to use different colors from the current theme.alpha = 0.38f
applies translucency. It will not turn a purple button to a grey one.masteramyx
11/01/2023, 4:06 PMKirill Grouchnikov
11/01/2023, 4:11 PMgraphicsLayer
with a 38% alpha on your container. You can add a 62% translucent container on top of everything (sort of like a milky glass overlay). You can override composition locals for the MaterialTheme
and tweak all the colors in it.cah
11/01/2023, 6:55 PM