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

David Edwards

02/18/2021, 12:19 PM
Is there a replacement for
Spinner
yet?
j

jaqxues

02/18/2021, 12:36 PM
DropDownMenu
d

David Edwards

02/18/2021, 12:36 PM
Isn't that a replacement for the PopupMenu? Hmm, I suppose I could combine that with a Button.
j

jaqxues

02/18/2021, 12:43 PM
Yes, for a spinner, use a Box where you put a Button and a DropDownMenu (so the menu is anchored correctly). With a correct toggle mechanism, this should give you a correct Spinner behaviour.
1
a

Archie

03/01/2021, 12:38 PM
Hi @jaqxues, How do you make the DropDownMenu equal to the size of the parent?
j

jaqxues

03/01/2021, 12:47 PM
Well since you already have a box around it, just tell DropDownMenu fillMaxWidth
a

Archie

03/01/2021, 12:50 PM
Unfortunately it exceeds its box. Do you have some sample code I could look at. I maybe I'm missing something. In my understanding this is expected though as the DropDownItems are in a seperate window out and not in the same "plane" as its parent's Box.
d

David Edwards

03/01/2021, 12:54 PM
You can probably use onSizeChanged to layout the width of the drop down? https://jetc.dev/slack/2021-02-14-how-big-are-we.html
a

Archie

03/01/2021, 12:56 PM
Hi @David Edwards, I also did try that but onSizeChanged returns IntSize but size modifiers expects Dp. Would IntSize to Dp be fine?
d

David Edwards

03/01/2021, 12:56 PM
Int probably represents the pixel size, so
.dp
would probably work in that case. Test and find out.
a

Archie

03/01/2021, 12:57 PM
Alright thanks for the tip. Let me try it out.
Hi @David Edwards, it worked! Thanks for the tip!
🎉 1