androidstudioにて、以下のコードからなる図形に対して、
画面をタッチした時に、その座標が、赤もしくは緑の弧に含まれるかの判定をしたいのですが、
方法がわからずにいます。
タッチイベントで座標を取得し、座標データを利用する方法がよいのか、
または、全く違う方法があるのか・・・・
よい方法があれば、ご教示をお願い致します。
public class Circle extends View{ public Circle(Context context) { super(context); } @Override protected void onDraw(Canvas canvas) { Paint paint1 = new Paint(); paint1.setColor(Color.argb(255, 255, 0, 0));//red Paint paint2 = new Paint(); paint2.setColor(Color.argb(255,0,255,0));//green RectF oval1 = new RectF(20.0f, 20.0f, 400.0f, 400.0f); RectF oval2 = new RectF(20.0f, 20.0f, 400.0f, 400.0f); canvas.drawArc(oval1, 0, 180, true, paint1); canvas.drawArc(oval2, 180, 180, true, paint2); paint1.setAntiAlias(true); paint2.setAntiAlias(true); } }
回答2件
あなたの回答
tips
プレビュー