Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 988
Nuke Avatar asked Jan 18 '26 07:01

Nuke


1 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);
}
like image 188
Priyanka Avatar answered Jan 20 '26 21:01

Priyanka