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

Bobby Hargett

02/28/2024, 9:27 PM
What is the best way of creating this view:
So a progressbar holder with a gradient progress bar. The bar can also be in the middle, meaning there is empty space on both sides of the gradient instead of just at the end
here is what I have so far:
Copy code
@Composable
fun DualSidedProgress(

) {
    Box(
        modifier = Modifier.fillMaxWidth().height(80.dp)
            .drawBehind
            {
                val radius = CornerRadius(40.dp.toPx())
                drawRoundRect(Color.White, cornerRadius = radius)
                drawRoundRect(
                    Brush.linearGradient(listOf(Color.Black, Color.Red)),
                    topLeft = Offset(40f, 0f),
                    size = this.size.copy(width = this.size.width * .95f),
                    cornerRadius = radius
                )
            }
    ) {
    }
}
final comment it is a static view no animation
k

Kirill Grouchnikov

02/28/2024, 10:58 PM
You can collapse the box and the modifier to a
Canvas
and leave the drawing logic as it is
1
4 Views