I would like to calculate the color depending on a percentage value:
float percentage = x/total; int color; if (percentage >= 0.95) { color = Color.GREE
As an updated solution, you can use ColorUtils#blendARGB from the Android support or AndroidX APIs:
ColorUtils#blendARGB
val startColor = ContextCompat.getColor(context, R.color.white) val endColor = ContextCompat.getColor(context, R.color.yellow) ColorUtils.blendARGB(startColor, endColor, 0.75)