Sam
10/09/2020, 12:27 AM<activity android:colorMode="wideColorGamut" …>
in AndroidManifest.xml
and using the colorSpace but it definitely does not look like the right color:
Color(red = r, green = g, blue = b, alpha = 1f, colorSpace = ColorSpaces.DisplayP3)
romainguy
10/09/2020, 12:29 AMSam
10/09/2020, 12:31 AMdrawLayer
that takes is able to take a background brush of type LinearGradient
but only uses the last color within the gradient:
SurfaceLayout(
modifier.drawLayer(shadowElevation = elevationPx, shape = shape)
.zIndex(elevation.value)
.then(if (border != null) Modifier.border(border, shape) else Modifier)
.background(
brush = LinearGradient.pink,
shape = shape
)
.clip(shape)
) {
Providers(ContentColorAmbient provides contentColor, children = content)
}
Modifier.background
romainguy
10/09/2020, 1:02 AMSam
10/09/2020, 1:04 AMLinearGradient
, specifically the endX
and endY
parameters. The brush is expected to know the size of the button/surface, these values look to be relative to the size of what is being drawn. I had the wrong values here, effectively saturating the whole surface with teh second color.nickbutcher
10/09/2020, 1:43 PMdrawWithCache
Modifier which should help you to create and cache your gradient brush when the size is known e.g. https://github.com/android/compose-samples/blob/main/Jetsnack/app/src/main/java/com/example/jetsnack/ui/components/Gradient.kt#L42Sam
10/09/2020, 5:16 PM