any ideas on how to implement a fading edge (the i...
# compose
m
any ideas on how to implement a fading edge (the items fade way in the edge) into a lazy column with transparent background?
I've figured out. Solution:
Copy code
Modifier.graphicsLayer { alpha = 0.99F }
                .drawWithContent {
                    val colors = mutableListOf(Color.Transparent)
                        .apply { repeat(50){ add(Color.Black) } }
                        .apply { add(Color.Transparent) }
                    drawContent()
                    drawRect(
                        brush = Brush.verticalGradient(colors.toList()),
                        blendMode = BlendMode.DstIn
                    )
                }
the trick was the graphicsLayer alpha = 0.99f. Explanation: https://stackoverflow.com/questions/66762472/how-to-add-fading-edge-effect-to-android-jetpack-compose-column-or-row
a
I think there are some new APIs in
1.4.0
coming that allow you to be more explicit than the
0.99f
trick: https://developer.android.com/jetpack/compose/graphics/draw/modifiers#compositing-strategy
m
testing here, the
CompositingStrategy.Always
also works! But I need to study to understand them better
297 Views