Does material specifically forbid alpha in the pop...
# compose
l
Does material specifically forbid alpha in the popup for a dropdown menu? It appears that ExposedDropDownMenu does not support this, so I had to copy the source code from
ExposedDropDownMenu
,
AndroidMenu
,
ExposedDropDownMenuPopup
, and
Menu
and explicitly handle the case where the popup background should have alpha. Is this a bug in Compose, where I should contribute the ‘fix’, or is this expected behavior? For reference, if you set Modifier.background to a color with alpha on ExposedDropDownMenu, you can see there is always an opaque white background applied behind.
c
It’s not explicitly forbidden but it is implicitly not recommended as the design specs don’t have any indication of using transparency in menus and overlays. Is this a design requirement for your app?
l
Yes. I need the dropdown to have an alpha of 0.611
c
Also FWIW, adding transparency to the background of a menu or overlay in Compose will not be a great result because of shadow which is also in those components. Applying an alpha will expose the shadow layer behind which is not desirable. This is likely why there is still an opaque background applied behind.
l
For now, I created a package and copied the relevant sources of ExposedDropDownMenu, then added an alpha to PopupLayout
c
I see - what does it look like now (assuming you removed the opaque background)?
l
I can see the content that is behind the dropdown menu now. It looks like a normal popup with alpha. I did have to apply the alpha to the whole popup, not the background color, so I can’t have anything fully opaque. I tried setting the background color of the PopupLayout, which is what the design specs wanted, but that didn’t seem to work. I’m just going to see if the design team is happy with the text in the options being partially transparent too.
c
Curious, do you have a mock of the intended design?
l
Not currently. We’re between design tools right now, so I just got a verbal description. The drop down should let the user choose between several options. The background color of the dropdown’s popup is supposed to be black with an alpha of 0.611 and the text should be white.
c
Gotcha. 0.611 is quite specific…
l
I may take some time some weekend and see if I can get it properly working where the background can have alpha, instead of applying it to the whole popup. Would this be something that I should make a PR for on compose-ui if I can figure it out?
c
I’m not sure it would be accepted since the decision to NOT have alpha in menus is based on the Material Design spec and also seems to be an Android OS wide decision as well (implicitly at least when I look at the many menus/overlays/dialogs). So I’m not sure we’d accept this into the core since it seems this is a design decision meant for an individual app.
I think it may be better to create a feature request so we can track if other developers/apps would like this functionality, and then we’ll decide accordingly how to execute in the core libraries
l
Sounds good. I’d assume I need to use the google sources androidx repo to create the feature request?
c
Oh I meant on Issue Tracker. But creating a pull request is also helpful if it’s not too much effort, and yes that’d be on androidx
l
Sorry, I meant issue tracker too. Creating an issue now and marking it as a feature request.
c
Thanks!