2012-01-18 12 views

答えて

1

私は、背景色と同じクリッピング地域(私の場合は円)の色を作ることによって、これを行うことができました。

float[] outerR = new float[] { 12, 12, 12, 12, 0, 0, 0, 0 };
float[] circleR = new float[] { 50, 50, 50, 50, 50, 50, 50, 50 };

mDrawables = new ShapeDrawable[2]; 
mDrawables[0] = new ShapeDrawable(new RoundRectShape(outerR, null, 
       null)); 
mDrawables[1] = new ShapeDrawable(new RoundRectShape(circleR, null, 
       null)); 
mDrawables[0].getPaint().setColor(0xFF0000FF); 
mDrawables[1].getPaint().setColor(Color.GRAY); 



そしてonDrawで:

protected void onDraw(Canvas canvas) { 
    canvas.drawColor(Color.GRAY); 
    int x = 10;<br> 
    int y = 10;<br> 
    int width = 100;<br> 
    int height = 100; 

    for (int i = 0; i < mDrawables.length; i++) { 
    Drawable dr = mDrawables[i]; 
    if (i == 0) { 
      dr.setBounds(x, y, x + width, y + height); 
      dr.draw(canvas); 
     } else { 
      x = 10 + 75; 
      y = 10 + 75; 
      dr.setBounds(x, y, x + 50, y + 50); 
      dr.draw(canvas); 
     } 
    } 
    canvas.save(); 
} 

It looked like this on my emuloator

関連する問題