I needed a [Material ExposedDropdownMenu](<https:/...
# compose
d
I needed a [Material ExposedDropdownMenu](https://material.io/components/menus#exposed-dropdown-menu), so I built one by combining an OutlinedTextField and a DropdownMenu. What I've built works, but feels a little hacky. I ended up needing to use SubcomposeLayout and MutableInteractionSource for the first time. Does that sound reasonable? The code: https://gist.github.com/danielzfranklin/6af017eec110dee4980167bb833077ef I use SubcomposeLayout because DropdownMenu opens a popup outside the normal flow, so if I want it to be properly positioned and sized I need to know the size of the field. I use MutableInteractionSource to make the text field focused when the menu is expanded, and visa-versa.
But not happy with the result
d
You might find what I did to properly set the width of the drop-down useful
t
Looks great! By the way, have you seen the following? It may be interesting to see what they did. https://android-review.googlesource.com/c/platform/frameworks/support/+/1539606
d
Darn. Wish I'd noticed that...
t
Well I tried it and it does not work really well (talking about the gerrit link), but that is probably why it hasn't been merged. Maybe it contains something you find useful.
d
Yeah, its a pretty similar general approach to what I ended up with
One of the things I think they do better is using the
FocusRequester
api instead of a
MutableInteractionSource
, which I didn't know about
They also change the DropdownMenu API to remove the need for the SubcomposeLayout I use