【发布时间】:2016-08-05 11:13:44
【问题描述】:
【问题讨论】:
标签: android linechart mpandroidchart
【问题讨论】:
标签: android linechart mpandroidchart
我找到了答案
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>
但仅在 api 级别 18 及更高级别支持填充可绘制
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);
}
【讨论】:
setDrawFilled(true) 才能使渐变可用。感谢代码 sn-p!