https://kotlinlang.org logo
#compose
Title
# compose
j

Javier

12/15/2021, 3:44 PM
Is it possible to change the compositionLocal inside AppBar to avoid adding an alpha to the content?
1
l

Louis Pullen-Freilich [G]

12/15/2021, 4:22 PM
You can just explicitly set a new value for
LocalContentAlpha
inside, or explicitly ignore it by doing
color = LocalContentColor.current
(and ignoring the alpha that is usually applied to text / icons)
👍 1
j

Javier

12/15/2021, 4:30 PM
But because the inner one is using
medium
instead of
high
(which I want to use), even if I provide one, the inner one will be used no? because the implementation detail inside material is wrapping the surface with the content, and mine is wrapping that, but it is external 🤔
c

Chris Sinco [G]

12/15/2021, 4:42 PM
It should resolve to the closest LocalContentAlpha, which would be yours because your change is within
content()
👍 1
I’ve done this successfully with content slots in
TopAppBar
like for the actions slot.
For example:
Copy code
actions = {
    Icon(
        ...,
        tint = LocalContentColor.current.copy(alpha = ContentAlpha.high)
    )
}
4 Views