I have a custom `layout` that essentially measures...
# compose
n
I have a custom
layout
that essentially measures the widest content in the layout and then sets the width of the dividing line to its value, and the width of the entire layout is determined by the width of the largest subitem. This results in my
clickable
taking effect in different areas, only the maximum width of the child's clickable takes effect in the normal area, the others are all their own width, is there a good way to solve this problem? 🤔
s
In your layout, go over all items and ask for their max intrinsic width before you actually measure them. Then use that width as the constraints for all of your items, so they all have the same fixed width. I believe that should work.
n
that's what I was thinking, but it seems that it would have to measure the layout twice, and use the results from the first measurement as Constraints in the second measurement. 🤔
s
That's why there's a specific function to measure the intrinsic width/height only, inside your layout function lambda. To not double measure the real thing Some example: https://github.com/HedvigInsurance/android/blob/4eeb8aee6c28bba871551e2ac005bc411f[…]ig/android/core/ui/text/HorizontalItemsWithMaximumSpaceTaken.kt
n
oh nice, it works ! that is what i need ! i didnt know this method 🥹, thanks a lot ! ❤️
🤗 1
🦜 1