0
我需要畫一個空圈,邊距爲10像素。我遇到的問題是我需要在2秒內模擬圓的繪製,然後在另一個顏色的另一個上面開始繪製。我使用自定義視圖,並試圖將我的邏輯實現爲onDraw方法,並使視圖每隔50毫秒失效。問題是我無法設法畫出圓圈......我只繪製了人體的數字。有人知道我如何繪製一個圓圈,而不使用canvas.drawCircle方法,因爲該方法直接繪製圓圈而沒有動畫。在模擬動畫的畫布上畫圓圈android
我當前的代碼
public class CustomAnimationView extends View{
private Canvas canvas;
private int count = 0;
private Paint paint;
private int mLeft;
private int mRight;
private int mBottom;
private int mTop;
public CustomAnimationView(Context context) {
super(context);
}
public CustomAnimationView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomAnimationView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setAttributes(attrs);
}
private void setAttributes(AttributeSet attrs) {
}
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
this.canvas = canvas;
if(paint == null){
paint = new Paint();
paint.setAntiAlias(true);
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(10);
paint.setColor(Color.BLACK);
}
if(count<150){
drawFirstQuarter(count);
}
count++;
}
public void drawFirstQuarter(int count){
RectF oval = new RectF(mLeft, mTop, mRight, mBottom);
canvas.drawArc(oval, 90, 30, true, paint);
}
public void setRect(int top, int bottom, int left, int right){
mBottom = bottom;
mTop = top;
mLeft = left;
mRight = right;
}
}
現在我只是特林畫有點圓的。
您可以發佈您當前的自定義視圖的代碼? – petey 2014-12-02 15:16:28