Is it somehow possible to change alpha of measurab...
# compose
z
Is it somehow possible to change alpha of measurables/placeables when using Layout?
k
This shouldn't be part of measure or layout
z
how would I achieve that then?
I have also tried wrapping the content elements in a box, setting the alpha to a remember{ Array(...) }, but the alpha is not updated
k
Whatever indicator you have that determines the size or position of a child element, should be used to determine the alpha of that element. Without knowing the specific scenario, it's a bit difficult to give a specific answer.
z
say I want to make something like a word cloud, where the elements alpha should be reduced the further they are from a certain word
k
How do you determine the location of a word during the layout pass? Whatever is the core factor in that decision would also be used to compute your alpha
Another option of course is to implement the whole thing as one canvas that draws elements without having them as child composables
z
I put the word in the center, but really it's supposed to be more interactive, like tapping on a word highlights it and makes the others lose alpha
I'd prefer not to go the canvas way, as this is the only thing that's missing in my current implementation
I even have the calculation of alpha ready, I'd just need to set it
also, currently the elements are Texts, but may also be images and whatnot in the future
l
You can use
Placeable.placeWithLayer
, and set alpha on the layer
1
♥️ 1
z
thank you!
that does exactly what I want it to! this works perfectly!