MPAndroidChart填充颜色渐变 [英] MPAndroidChart fill color gradient

查看:117
本文介绍了MPAndroidChart填充颜色渐变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用MPAndroidChart(或任何其他Android图表库)是否可以使用渐变颜色在绘制线下方填充图表?像这样:

Is it possible with MPAndroidChart (or any other Android chart library) to fill the chart under the draw line with a gradient color? Something like this:

set1.setFillColor(getResources().getColor(R.drawable.chart_fill));

然后在chart_fill.xml中输入:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <gradient
        android:angle="90"
        android:endColor="#FF207a54"
        android:startColor="#FFffffff" />

</shape>

推荐答案

好的,我已经找到了解决方法:

Okay i have found a solution:

威廉图表,我正在使用这种方法:

William Chart and i am using this method:

int[] colors = { getResources().getColor(R.color.menu_text),
 getResources().getColor(android.R.color.white) };

float[] index = { 0, 1 };
dataset.setGradientFill(colors, index);

这篇关于MPAndroidChart填充颜色渐变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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