1
ボタンのOnClickメソッドでは、画面上の位置をランダム化しています... これは完璧に機能しますが、2つまたは3つのボタンを使用して位置をランダム化すると、お互いにワンボタンhalflyは、他のボタンに重なって...ここ無作為化されたボタンが重なり合うことがあります
は、ボタンのランダムな位置のための方法である -
private void moveButton()
{
if(!canMove){ return; }
runOnUiThread(
new Runnable()
{
@Override
public void run()
{
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
Button button = (Button)findViewById(R.id.button);
Random r = new Random();
int startX = width/2;
int startY = height/2;
if(myscores==0){
button.setX(startX);
button.setY(startY);
}
else {
int x = r.nextInt(width - 210);
int y = r.nextInt(height - 200);
button.setX(x);
button.setY(y);
}
}
}
);
}
すべてのヘルプ高く評価されるだろう:)
ここで、「その他」は別のボタンを意味しますか? :) – DarShan
@ダルシャンはい、そうです。 –
ありがとうございます:)チャームのような作品:D – DarShan