Looking at design documentation of <NavigationBar>...
# compose
g
Looking at design documentation of NavigationBar from material3, the
secondaryContainer
is the property used to change active item color. But, apparently, it completely ignores the alpha channel. Any Idea why?
Copy code
@Composable
fun NavigationBarTheme(content: @Composable () -> Unit) {
    MaterialTheme(
        colorScheme = lightColorScheme(
            secondaryContainer = orange.copy(alpha = 0.3f) //val orange = Color(0xFFFF5704)
        ),
        ...
    )
}
l
It seems common for material containers to ignore alpha. I asked about this when I needed to apply alpha to a DropdownMenu, and the Google team said it wasn’t in the material spec.
f
I believe containers ignore alpha channel because items with elevation - shadow (usually containers) don't play nicely with transparency. That's just my interpretation tho
l
If you really want to apply an alpha, you can often go into the source code and copy the source for the Composable you are using, then modify it to fit your needs. I did that with the DropdownMenu popup.
g
@Filip Wiesner But you can always “hack” ARGB into the RGB, so they can’t prevent it 😅 But makes sense your point of view
@Landry Norris it was easier to convert ARGB to RGB in this case. The IDE color picker helped 😊
message has been deleted
f
Just saying that you can't really have elevation and transparency at the same time and containers do usually have elevation. That's all
l
That will work as long as you are placing it above a solid white background.
g
true! And that’s the case fortunatly
Well pointed 👍
g
If you want the code to have more clarity of which color was used, you can use compositeColor to place it on top of a solid color
Copy code
orange.copy(alpha = 0.3f).compositeOver(Color.WHITE)