2010-12-20 85 views

回答

0

Here是Java中的一個示例(不適用於Android)。您可以使用Canvas而非Graphics2D對象輕鬆地將其移植到Android上。例如,您可以使用drawArc而不是fillArc。

0

創建您自己的自定義View類並實現onDraw方法使用ArcShape繪製圖表。

然後,您可以將圖表組件包含在佈局中,就像您將其中一個內置組件一樣。

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(); 
    } 
} 

試試這個代碼

+0

良好.. + 1爲我身邊..thnx – ckpatel 2013-03-26 06:33:23