setDescriptionTextSize(float size) cannot resolve method MPAndroidChart

梦想的初衷 提交于 2019-12-10 23:37:44

问题


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.

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

Here is my code:

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?


回答1:


you can use

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

instead of

pieChart.setDescriptionTextSize(25f); 



回答2:


The value has to be between 6f and 16f. Other values aren't accepted.

setDescriptionTextSize(float size): Sets the size of the description text in pixels, min 6f, max 16f.



来源:https://stackoverflow.com/questions/50969952/setdescriptiontextsizefloat-size-cannot-resolve-method-mpandroidchart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!