MPCharts - Line Chart (gradient fill) is not working in API Level 16

Viewed 2177

im using line chart (MPCharts) gradient fill working perfectly with API Level 19 but not in API Level 16 (and bellow i guess). is it a bug or do i have to try in different manner?

Thanks.

I used These codes.

LineDataSet set1 = new LineDataSet(yVals, "Close");
Drawable drawable = ContextCompat.getDrawable(getApplication(),R.drawable.gradiant);
                drawable.setAlpha(200);
                set1.setFillDrawable(drawable);
                set1.setDrawFilled(true);

Screen Shots,

This is API level 16

This is API level 19

2 Answers
set1.setDrawFilled(true);
if (Utils.getSDKInt() >= 18) {
    // fill drawable only supported on api level 18 and above
    Drawable drawable = ContextCompat.getDrawable(this, R.drawable.gradiant);
    set1.setFillDrawable(drawable);
}
else {
    set1.setFillColor(Color.BLACK);
}

Here is a Kotlin solution for filling LineChart line bottom side.

Related