Java tutorial
//package com.java2s; import android.graphics.Color; public class Main { public static int getColor(float barValue) { barValue = Math.abs(barValue); if (barValue < 50) { return Color.GREEN; } else if (barValue >= 50 && barValue <= 100) { return Color.BLUE; } else if (barValue > 100 && barValue <= 200) { return Color.YELLOW; } return Color.RED; } }