Android 柱状图渐变 Barchar柱状图渐变 MPAndroidChart

479 阅读1分钟

MPAndroidChart柱状图渐变

在项目中的统计表需要做渐变效果,上网上查询只找到了如下方法:

//**渐变-需要下载源代码,才有fill方法
BarDataSet set1;
List<Fill> fills = new ArrayList<>();
fills.add(new Fill(Color.parseColor("#00397AE3"), Color.parseColor("#6E375BD3")));
set1.setFills(fills);

ps:设置渐变方法为.setFills(fills),如果是implementation V3.1的版本,这个方法会不存在,需要下载源代码然后到自己的库里面去。

在这里插入图片描述

原文地址:blog.csdn.net/qq_33902817… blog.csdn.net/czssltt/art…

但是我尝试了一下,现在的源代码里,没有了setFills(fills);

只能自己继续查看源代码

发现了这个方法setGradientColor

image.png

这句话的翻译:Sets the start and end color for gradient color, ONLY color that should be used for this DataSet. 设置渐变颜色的开始和结束颜色,应该用于此数据集的唯一颜色。

然后在代码里试了一下

set1.setGradientColor(Color.parseColor("#ffffff"),Color.parseColor("#2EBF62"));

下面是效果图

捕获.PNG

成功!!!!!!🎉

基础使用:blog.csdn.net/duoduo_1101…

www.jianshu.com/p/018935af6…

www.jianshu.com/p/fc73b490e…

git:github.com/PhilJay/MPA…