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

China☆狼群 提交于 2019-12-08 17:45:16

问题


github link

I would like a gradient and, if possible, choose components colors and orientation.

is this issues solved?


回答1:


i found it's 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 drawable only supported on 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);
}

reference MPAndroidChart - link



来源:https://stackoverflow.com/questions/38787872/how-to-solve-draw-gradient-below-line-philjay-mpandroidchart-issues-104

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!