我在HorizontalScrollView
内动态生成饼图。当我这样做时,饼图的标题默认设置为白色。如何在没有XML的情况下更改它(因为我没有XML)。下面是我用来动态生成图表的代码。
LinearLayout l_layout=chart_container;
LinearLayout.LayoutParams lp_view = new LinearLayout.LayoutParams(300,300);
PieChart pie = new PieChart(this,"BYE");
s1 = new Segment("s1", 10000);
s1.setTitle("10000");
s2 = new Segment("s2", 5000);
s2.setTitle("5000");
SegmentFormatter sf1 = new SegmentFormatter(getApplicationContext(), R.xml.pie_segment_formatter1);
sf1.getOuterEdgePaint().setColor(Color.TRANSPARENT);
SegmentFormatter sf2 = new SegmentFormatter(getApplicationContext(), R.xml.pie_segment_formatter2
sf2.getOuterEdgePaint().setColor(Color.TRANSPARENT);
pie.addSeries(s1, sf1);
pie.addSeries(s2, sf2);
pie.getBorderPaint().setColor(Color.TRANSPARENT);
pie.getBackgroundPaint().setColor(Color.TRANSPARENT);
pie.getRenderer(PieRenderer.class).setDonutSize(0.1f,PieRenderer.DonutMode.PERCENT);
pie.redraw();
l_layout.addView(pie, lp_view);
setupIntroAnimation(pie);
答案 0 :(得分:0)
这应该可以解决问题:
pie.getTitle().getLabelPaint().setColor(Color.RED);