Hi guys, is there any way we can set the backgroun...
# compose
s
Hi guys, is there any way we can set the background color of Dropdown as transparent. Actually if i use
Modifier.background(Color.Transparent)
It does not work, but if i use any other color here, it works.
Modifier.background(Color.Red)
So i just want to know why its not working and do we have any other way except doing it at theme level by changing the surface color, i dont want to do that. Please need some help.
s
Which dropdown composable is that? Maybe it has a
Surface
internally which is not customizable? Many m3 components have defaults to things like
Surface
but give you the option to pass in a custom color instead
If on the other hand it just uses for example MaterialTheme.colorScheme.surface and it’s not editable at all, you can wrap that composable with a
Copy code
val colorScheme = MaterialTheme.colorScheme
MaterialTheme(
  colorScheme = colorScheme.copy(surface = ...),
) {
  DropdownComposable()
}
So you only override it locally
s
Its DropdownMenu in m3. I guess it uses cardview internally. I tried the way you are suggesting but still some issues are there, like its not becoming fully transparent if i override surface color by this way and also it shows elevation color as well there in outline
s
It’s a common thing in m3 components that if they do not provide you with all the customization options in the parameters, that it’s simply not possible. m3 is its own design system with their own specs, which sometimes they constrain their components to follow. I have never used DropdownMenu myself, but it could very well be that you need to copy-paste the implementation and then tweak the implementation to your needs. Like removing the surface color, removing the elevation and the outline etc
s
Yeah that is the last option i see, but i was thinking of may be if someone did any workaroud that i could get here.