私はそのキャンバスが画面の外に円を描いていないことをどのように設定することができますか?スクリーンショットでは、それはこのようになります円の外に出ている画面のサイズ
- あなたが見ることができるように Click here to see image
、円の一部が画面の外に半分であるが、私は、円のすべてが画面内にあることを望みます。
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Random random = new Random();
int minRadius = 50;
int w = this.getWidth();
int h = this.getHeight();
Paint paint = new Paint();
for (int i=0; i<resultInt; i++) {
int red = (int) (Math.random() * 255);
int green = (int) (Math.random() * 255);
int blue = (int) (Math.random() * 255);
int randX = random.nextInt(w);
int randY = random.nextInt(h);
int color = Color.rgb(red, green, blue);
paint.setColor(color);
canvas.drawCircle(randX, randY, minRadius, paint);
}
}
}
}
:
そしてがランダム点を修正?いいえ – mac229
@ mac229編集、追加コード、申し訳ありません – Mee