在没有XML的AndroidPlot饼图中更改标题颜色



我在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);

这应该做技巧:

pie.getTitle().getLabelPaint().setColor(Color.RED);

最新更新