import android.support.v4.content.ContextCompact; private int getMagnitudeColor(double magnitude){ int magnitudeColorResourceId; int magnitudeFloor = (int) Math.floor(magnitude); switch(magnitudeFloor){ case 0: case 1: magnitudeColorResourceId = R.color.magnitude1; break; case 2: magnitudeColorResourceId = R.color.magnitude2; break; case 3: magnitudeColorResourceId = R.color.magnitude3; break; case 4: magnitudeColorResourceId = R.color.magnitude4; break; case 5: magnitudeColorResourceId = R.color.magnitude5; break; case 6: magnitudeColorResourceId = R.color.magnitude6; break; case 7: magnitudeColorResourceId = R.color.magnitude7; break; case 8: magnitudeColorResourceId = R.color.magnitude8; break; case 9: magnitudeColorResourceId = R.color.magnitude9; break; default: magnitudeColorResourceId = R.color.magnitude10plus; break; } return ContextCompact.getColor(getContext(), magnitudeColorResourceID); } }
<color name="textColorEarthquakeDetails">#B4BAC0</color> <color name="textColorEarthquakeDetails">#2B3D4D</color>