上篇寫了自定義圓環(huán)進(jìn)度條鼎俘,在上篇的基礎(chǔ)上自定義了稍微復(fù)雜一點(diǎn)的控件寞肖,模仿支付寶芝麻信用進(jìn)度圓環(huán)纲酗。
代碼下載
效果圖如下
效果圖
畫扇形
RectF rectF=new RectF(left,top,right,bottom)
canvas.drawArc(rectF, startAngle, sweepAngle, false, ringPaint);//第三個(gè)參數(shù)是否顯示半徑
將文字沿著圓環(huán)內(nèi)測顯示
path.addOval(rectF, Path.Direction.CW);//Path.Direction.CCW逆時(shí)針
canvas.drawTextOnPath(text,path,hOffset,vOffset,paint);
帶有陰影的圓點(diǎn)
pointPaint.setShadowLayer(pointShadowLayer, x, y, Color.WHITE);//設(shè)置陰影
canvas.drawCircle(xPoint, yPoint, pointPaintSize, pointPaint);
動(dòng)畫依舊使用Animation,重寫applyTransformation方法
gif.gif