https://kotlinlang.org logo
Title
l

Lucas Kivi

01/26/2023, 6:05 AM
Hello, Androids! I have an expandable component and I need to know both the height of its expanded and collapsed states prior to the first layout. I have a semi ugly solution and I am wondering if anyone has anything more graceful! My solution essentially builds an expanded and collapsed instance of the component, measures them, returns the measurements via a callback, and then does not lay them out. If you need me to provide more details I can but the crux of the question is the first sentence: “how can I measure two different states of one component prior to the first layout”.
j

jossiwolf

01/26/2023, 9:17 AM
What's your use case? Why does it need to know the height before layout? It's a quite nuanced problem so more details would be helpful
l

Lucas Kivi

01/26/2023, 3:39 PM
The variable sized component is the toolbar here:
I need these values for setting the anchors for the swipeable bottom sheet. This is obviously a bare bones toolbar but the real implementation has multiple components that animate as the toolbar expands and collapses.
The reason it should know before the first layout is so the bottom sheet can be initialized with the correct anchors
j

jossiwolf

01/26/2023, 4:14 PM
What bottom sheet are we talking about - is it a custom component?
l

Lucas Kivi

01/26/2023, 4:14 PM
it is a custom one!
I need four anchors