2015-09-06 20 views

回答

2

研究源代碼後,我改變PieChartRenderer.java改變 mCenterTextPaint.setColor(Color.parseColor("#333333")); mCenterTextPaint.setTextSize(Utils.convertDpToPixel(20f)); mCenterTextPaint.setTextAlign(Align.CENTER);

然後使用「\ n」作爲分裂拿到第一線

int index = centerText.indexOf("\n"); 

    Spannable tempSpannable = new SpannableString(centerText); 
    tempSpannable.setSpan(new RelativeSizeSpan(0.75f), 0, index, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); 
    tempSpannable.setSpan(new ForegroundColorSpan(Color.parseColor("#999999")), 
         0, index, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); 

    // If width is 0, it will crash. Always have a minimum of 1 
    mCenterTextLayout = new StaticLayout(tempSpannable, 0, centerText.length(), 
         mCenterTextPaint, 
         (int)Math.max(Math.ceil(mCenterTextLastBounds.width()), 1.f), 
         Layout.Alignment.ALIGN_NORMAL, 1.f, 0.f, false); 

然後得到了什麼我想要的是 enter image description here

0
PieData data = new PieData(dataSet); 
pieChart.setCenterText("Total Questions 5");   
pieChart.setCenterTextSize(14f); 
pieChart.setCenterTextColor(Color.BLUE); 
相關問題