gpt4 book ai didi

android - MPCharts - 折线图(渐变填充)在 API 级别 16 中不起作用

转载 作者:太空狗 更新时间:2023-10-29 14:00:37 24 4
gpt4 key购买 nike

我使用折线图 (MPCharts) 渐变填充与 API 级别 19 完美配合,但不适用于 API 级别 16(我猜是下面的)。这是一个错误还是我必须以不同的方式尝试?

谢谢。

我使用了这些代码。

LineDataSet set1 = new LineDataSet(yVals, "Close");
Drawable drawable = ContextCompat.getDrawable(getApplication(),R.drawable.gradiant);
drawable.setAlpha(200);
set1.setFillDrawable(drawable);
set1.setDrawFilled(true);

屏幕截图,

This is API level 16

This is API level 19

最佳答案

set1.setDrawFilled(true);
if (Utils.getSDKInt() >= 18) {
// fill drawable only supported on api level 18 and above
Drawable drawable = ContextCompat.getDrawable(this, R.drawable.gradiant);
set1.setFillDrawable(drawable);
}
else {
set1.setFillColor(Color.BLACK);
}

关于android - MPCharts - 折线图(渐变填充)在 API 级别 16 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35910342/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com