2013-04-30 49 views
6

enter image description here圈與Android的

慢充顏色我想首先展示透明色圈,它應該在那個圈子裏填充一種顏色慢。我嘗試通過使用圓形進度欄,但我沒有得到正確的結果。任何人都可以幫助我像這張照片一樣達到這個輸出。

+1

[參考這個類似的代碼。(https://github.com/Todd-Davies/ProgressWheel) – Laksh 2013-04-30 09:08:38

+0

謝謝,明白了.... – Android 2013-04-30 09:17:51

回答

4

試試這段代碼來創建一個填充顏色的圓。傳遞它的整數值來繪製填充面積的百分比。 :)

private void circularImageBar(ImageView iv2, int i) { 

    Bitmap b = Bitmap.createBitmap(300, 300,Bitmap.Config.ARGB_8888); 
    Canvas canvas = new Canvas(b); 
    Paint paint = new Paint(); 

     paint.setColor(Color.parseColor("#c4c4c4")); 
     paint.setStrokeWidth(10); 
     paint.setStyle(Paint.Style.STROKE); 
     canvas.drawCircle(150, 150, 140, paint); 
     paint.setColor(Color.parseColor("#FFDB4C")); 
     paint.setStrokeWidth(10); 
     paint.setStyle(Paint.Style.FILL); 
     final RectF oval = new RectF(); 
     paint.setStyle(Paint.Style.STROKE); 
     oval.set(10,10,290,290); 
     canvas.drawArc(oval, 270, ((i*360)/100), false, paint); 
     paint.setStrokeWidth(0);  
     paint.setTextAlign(Align.CENTER); 
     paint.setColor(Color.parseColor("#8E8E93")); 
     paint.setTextSize(140); 
     canvas.drawText(""+i, 150, 150+(paint.getTextSize()/3), paint); 
     iv2.setImageBitmap(b); 
}