Solution from codereview.stackexchange.com worked for me.

protected void drawCubicBezier(ILineDataSet dataSet) {
...
// Get screen coordinates for min Y value
MPPointD pixelForValues = trans.getPixelForValues(0, minDy);
minDy = (float) pixelForValues.y;
MPPointD.recycleInstance(pixelForValues);
// Get screen coordinates for max Y value
pixelForValues = trans.getPixelForValues(0, maxDy);
maxDy = (float) pixelForValues.y;
MPPointD.recycleInstance(pixelForValues);
// Get screen coordinates for 0 value
pixelForValues = trans.getPixelForValues(0, 0);
float zeroDy = (float) pixelForValues.y;
MPPointD.recycleInstance(pixelForValues);
float range = minDy - maxDy;
float zeroPointNormalized = Math.max((zeroDy - maxDy) / range, 0);
linearGradient = new LinearGradient(
0, maxDy, 0, minDy,
new int[]{Color.RED, Color.RED, Color.BLUE, Color.BLUE},
new float[]{0, zeroPointNormalized, zeroPointNormalized, 1f},
Shader.TileMode.REPEAT);
paint.setShader(linearGradient);
...
mBitmapCanvas.drawPath(cubicPath, paint);
}