我需要手动绘制饼图。我需要一些基本的想法来做到这一点。任何人都可以帮助我吗?
答案 0 :(得分:3)
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DemoView demoView=new DemoView(getBaseContext());
setContentView(demoView);
}
private class DemoView extends View{
public DemoView(Context context){
super(context);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
RectF mBigOval = new RectF(40, 10, 280, 250);
Paint p = new Paint();
DashPathEffect dashPath = new DashPathEffect(new float[]{5,5}, (float)1.0);
PathEffect path=new PathEffect();
p.setPathEffect(path);
p.setStyle(Style.FILL_AND_STROKE);
p.setColor(android.graphics.Color.GREEN);
canvas.drawArc(mBigOval, 0, 360, true, p);
p.setColor(Color.RED);
canvas.drawArc(mBigOval, 0, 240, true, p);
invalidate();
}
}
试试这段代码
答案 1 :(得分:0)
答案 2 :(得分:0)
答案 3 :(得分:0)
我已经创建了一个库来执行您要查找的内容(https://github.com/saulpower/ExpandablePieChart)。