2014-01-14 56 views

回答

2

不,你不能設置爲不同的顏色每u必須編輯庫

把這些功能放到DefaultRenderer

private int[] mLabelsColors = {TEXT_COLOR}; 

public int[] getLabelsColors() { 
    return mLabelsColors; 
    } 

public void setLabelsColors(int[] col) { 
    // TODO Auto-generated method stub 
    mLabelsColors = col; 
    } 

餅圖做這樣的事情,但要小心數組的大小

if(i==0) 
     drawLabel(canvas, mDataset.getCategory(i), mRenderer, prevLabelsBounds, mCenterX, mCenterY, 
      shortRadius, longRadius, currentAngle, angle, left, right, mRenderer.getLabelsColors()[0], 
      paint, true, false); 
     if(i==1) 
     drawLabel(canvas, mDataset.getCategory(i), mRenderer, prevLabelsBounds, mCenterX, mCenterY, 
      shortRadius, longRadius, currentAngle, angle, left, right, mRenderer.getLabelsColors()[1], 
      paint, true, false); 

     if(i==2) 
     drawLabel(canvas, mDataset.getCategory(i), mRenderer, prevLabelsBounds, mCenterX, mCenterY, 
      shortRadius, longRadius, currentAngle, angle, left, right, mRenderer.getLabelsColors()[2], 
      paint, true, false); 

     if(i==3) 
     drawLabel(canvas, mDataset.getCategory(i), mRenderer, prevLabelsBounds, mCenterX, mCenterY, 
      shortRadius, longRadius, currentAngle, angle, left, right, mRenderer.getLabelsColors()[3], 
      paint, true, false); 

而且其中u創建甜菜使用

int Col[] ={Color.BLACK,Color.BLUE,Color.CYAN,Color.GREEN,Color.RED}; 

    mRenderer.setLabelsColors(Col); 
+0

感謝凱沙夫,它爲我工作 – Abx

0

你需要保持一個顏色數組作爲類DefaultRenderer在以下link

相關問題