setDescriptionTextSize(float size)无法解析方法MPAndroidChart [英] setDescriptionTextSize(float size) cannot resolve method MPAndroidChart

查看:200
本文介绍了setDescriptionTextSize(float size)无法解析方法MPAndroidChart的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在android studio中制作PieChart,但遇到了样式方面的一些问题.描述的大小(图例和值确实很小). 我阅读了关于此文档,它说在那里,我不得不使用setDescriptionTextSize()方法,并且该方法可用于每种图表类型.
但是由于某种原因该方法无法解决.

I am making a PieChart in android studio but am running into some issues with styling. The size of description (and legend and values are really small). I read the docs about this and it said there i had to use the setDescriptionTextSize() method and that it is available for every chart type.
However that method is not resolved for some reason.

有关项目的其他信息:
-问题出现在片段中
-my pieChart是在"onChildAdded"方法中构建的,因为在该函数运行时需要创建它.
-MPAndroidChart版本为:v3.0.3

extra info about project:
-the problem occurs in a fragment
-my pieChart is built in the "onChildAdded" method because it needs to be created when that function runs.
-the MPAndroidChart version is: v3.0.3

这是我的代码:

pieChart = (PieChart) myView.findViewById(R.id.idPieChart);
pieChart.setCenterTextSize(25f);
pieChart.setUsePercentValues(true);
pieChart.setExtraOffsets(5, 10, 5, 5);
pieChart.setDrawHoleEnabled(true);
pieChart.setHoleColor(Color.WHITE);
pieChart.setTransparentCircleRadius(61f);
pieChart.setEntryLabelTextSize(25f);
pieChart.setUsePercentValues(true);
pieChart.setDescriptionTextSize(25f);  //THIS IS NOT RESOLVED

List<PieEntry> entries = new ArrayList<>();

entries.add(new PieEntry(likeCount.getLikes(), "Leuk"));
entries.add(new PieEntry(likeCount.getDislikes(), "Niet leuk"));
PieDataSet set = new PieDataSet(entries, "likes/dislikes");
PieData data = new PieData(set);
set.setColors(getResources().getColor(R.color.chartgreen)
                ,getResources().getColor(R.color.chartred));
pieChart.setData(data);
pieChart.invalidate(); // refresh

有人知道这个问题的可能解决方案吗?

Does anyone know a possible solution to this problem?

推荐答案

您可以使用

pieChart.getDescription().setTextSize(25f);

代替

pieChart.setDescriptionTextSize(25f); 

这篇关于setDescriptionTextSize(float size)无法解析方法MPAndroidChart的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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