How to solve the drawing gradient below the line - PhilJay / MPAndroidChart / issues / 104?

github link

I need a gradient and, if possible, select the colors and orientation of the components.

Are these issues being addressed?

enter image description here

+4
source share
1 answer

I found the answer

LineDataSet set1 = new LineDataSet(values, "DataSet 1");
Drawable drawable = ContextCompat.getDrawable(this, R.drawable.fade_red);
set1.setFillDrawable(drawable);

fade_red.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
    android:angle="90"
    android:startColor="#00ffffff"
    android:endColor="#6a64c7ff" />
</shape>

but fill is only available at api level 18 and above

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

link MPAndroidChart - link

+10
source

Source: https://habr.com/ru/post/1650289/


All Articles