Hi! Greetings!
I'm working in onTouch method to draw a circle, what i'm trying is to draw 
a circle when user draws on the screen, without using any fixed radius. 
Radius should calculate from the distance. I've tried but it is not drawing 
what i want. Here is my code

@Override
public boolean onTouch(View bg, MotionEvent event) {
// TODO Auto-generated method stub
dumpEvent(event);

final int action = event.getAction();
switch (action & MotionEventCompat.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
downx = event.getX();
downy = event.getY();
xaxis.clear();
yaxis.clear();
Log.d(TAG, "DOWN");
break;

case MotionEvent.ACTION_MOVE:
//drawCircle(event);
for (int i = 0; i < event.getPointerCount(); i++) {
xaxis.add(Integer.valueOf((int) event.getX(i)));
yaxis.add(Integer.valueOf((int) event.getY(i)));
}
// Collections.sort(xaxis);
// Collections.sort(yaxis);
 Log.d(TAG, "DRAG");
return true;

case MotionEvent.ACTION_UP:
upx = event.getX();
upy = event.getY();

if (xaxis.size()==0 && yaxis.size()==0){
Log.d(TAG, "Arraylist is empty");
}
else {
minx = xaxis.get(0);
miny = yaxis.get(0);
 for (int i = 0; i < xaxis.size(); i++){
maxx = xaxis.get(i);
}
for (int j = 0; j < yaxis.size(); j++) {
maxy = yaxis.get(j);
}
 double temp = Math.pow((maxx - minx), 2)
 + Math.pow((maxy - miny), 2);
 float radius = (float) Math.sqrt(temp) / 2;
canvas.drawCircle(minx, miny, radius, paint); 
 }
 choosenImageView.invalidate();
mode = NONE;
Log.d(TAG, "mode=NONE");
return true;

 }
choosenImageView.invalidate();
return true;
}


Help needed!

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to