I'm stuck with this one implementation of material LinearProgressIndicator but have no idea on how I can make it functional in that way.
My naive approach is to have different color at different percentage level such as for "10%-Red, 25%-Yellow, 35%-Orange, 50%+ Green". So, I just wanted to know if there exist any other way for gradient color which starts from red and goes all above upto green.
Updated Question with picture

Something like this picture!
One of the solutions can be to generate a color from the progress and update it to the progress bar.
private fun updateProgress(progress: Int) {
val color = when (progress) {
in 0..10 -> Color.RED
in 11..34 -> Color.YELLOW
in 35..54 -> Color.MAGENTA
else -> Color.GREEN
}
updateProgressBar(progress, color)
}
private fun updateProgressBar(progress: Int, color: Int) {
binding.progressBar.apply {
setProgress(progress)
setIndicatorColor(color)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With