3

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

Nuke
  • 406
  • 3
  • 13

2 Answers2

1
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);
}
Priyanka
  • 19
  • 2
0

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

Md. Yamin Mollah
  • 1,609
  • 13
  • 26