如何解决线下的绘制渐变-PhilJay/MPAndroidChart/issues/104? [英] How to solve draw gradient below line - PhilJay/MPAndroidChart/issues/104?

查看:311
本文介绍了如何解决线下的绘制渐变-PhilJay/MPAndroidChart/issues/104?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

github链接

我想要一个渐变色,如果可能的话,请选择组件的颜色和方向.

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

这个问题解决了吗?

推荐答案

我找到了答案

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

fade_red.xml

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>

但填充绘图仅在api级别18及更高版本上受支持

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);
}

参考 MPAndroidChart-链接

这篇关于如何解决线下的绘制渐变-PhilJay/MPAndroidChart/issues/104?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆