https://kotlinlang.org logo
#compose
Title
# compose
m

mgrazianodecastro

01/19/2023, 8:19 PM
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

Alex Vanyo

01/19/2023, 9:06 PM
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

mgrazianodecastro

01/19/2023, 11:37 PM
testing here, the
CompositingStrategy.Always
also works! But I need to study to understand them better
236 Views