2011-06-20 114 views
0

我畫了幾個同心圓,現在我想帶來一些觸摸事件,以便當我可以調整(擴大/縮小)整個圓圈。是否可以這樣做呢?..如何使用觸摸事件調整Android中的視圖

這是我得出的觀點..

// DrawCircles.java

class DrawCircles extends View { 

private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 

public DrawCircles(Context context) { 
     super(context); 
     // TODO Auto-generated constructor stub 
} 


protected void onDraw(Canvas canvas) { 
     // TODO Auto-generated method stub 
    mPaint.setStyle(Paint.Style.STROKE); 
    mPaint.setStrokeWidth(2); 
    mPaint.setColor(0xFF000000); 
    int px = getMeasuredWidth() >>1; 
    int py = getMeasuredHeight()>>1 ; 
    int radius = Math.min(px, py); 
    int diff = radius/6; 
    canvas.drawCircle(px, py, radius, mPaint); 
    mPaint.setColor(0xFFFFFFFF); 
    canvas.drawCircle(px, py, radius-2, mPaint); 
    radius-=diff; 
    mPaint.setColor(0xFF000000); 
    canvas.drawCircle(px, py, radius, mPaint); 
    mPaint.setColor(0xFFFFFFFF); 
    canvas.drawCircle(px, py, radius-2, mPaint); 
    radius-=diff; 
    mPaint.setColor(0xFF000000); 
    canvas.drawCircle(px, py, radius, mPaint); 
    mPaint.setColor(0xFFFFFFFF); 
    canvas.drawCircle(px, py, radius-2, mPaint); 
    radius-=diff; 
    mPaint.setColor(0xFF000000); 
    canvas.drawCircle(px, py, radius, mPaint); 
    mPaint.setColor(0xFFFFFFFF); 
    canvas.drawCircle(px, py, radius-2, mPaint); 
    radius-=diff; 
    mPaint.setColor(0xFF000000); 
    canvas.drawCircle(px, py, radius, mPaint); 
    mPaint.setColor(0xFFFFFFFF); 
    canvas.drawCircle(px, py, radius-2, mPaint); 
    radius-=diff; 
    mPaint.setStyle(Paint.Style.FILL); 
    mPaint.setColor(0xFFFF0000); 
    canvas.drawCircle(px, py, radius, mPaint); 
    radius-=(diff/2); 
    mPaint.setColor(0xFFC11B17); 
    canvas.drawCircle(px, py, radius, mPaint); 
    mPaint.setColor(0xFFCFCFCF); 

     super.onDraw(canvas); 
} 

} 

請讓我知道,是否有可能如果是的話請提供相同的一些資源...

由於提前

回答

相關問題