https://kotlinlang.org logo
Title
o

Olivier Patry

03/22/2021, 10:28 PM
I have difficulties with
DropdownMenu
positioning.
x
coordinate of the menu is correct but the vertical position is wrong always stick to the bottom of the window. It seems close to https://github.com/JetBrains/compose-jb/issues/195 which is closed though. And the mechanic wasn't the same as of now it seems. You can see in the :thread-please: the details (code & screenshots)
As you can see, the horizontal position is fine, in second screenshot, it's triggered by the
(+)
in the white area, in the 3rd screenshot, by the
(+)
from the toolbar
When I debug the values of my anchors, they are perfectly correct, both for x & y coordinates.
What I noticed also is that the menu briefly appears at the right position (for a frame or 2) before landing at the bottom of the screen
here follows a screen capture
it seems I didn't properly understand the way
DropdownMenu
work. Using the sample code found here https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-main/c[…]in/java/androidx/compose/material/samples/MenuSamples.kt I understood I had to wrap both "anchor" and Dropdown within the same
Box
parent with proper
Modifier.wrapContentSize(<http://Alignment.XXX|Alignment.XXX>)
where XXX is the anchor rules for this configuration. It now works as intended.
👍 1
c

Chris Sinco [G]

03/23/2021, 2:20 AM
Yep, it uses the Box parent as the anchor.