2

enter image description here

in my application on ontouch of screen i'm getting the coordinates(x.y), after that on that position i'm drawing a circle.but when i'm drawing a circle on that position.it always draw a circle on upper left side corner of images on some pt.s .i'm not getting why this is happening.please help me.

        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub

             if(event.getAction()==MotionEvent.ACTION_UP) {

               Log.d("position", event.getX() + "-" + event.getY());
                   System.out.println("bitmap......"+paths[0]+"draw...."+dd);
                    Paint paint = new Paint();
                    paint.setAntiAlias(true);

                   paint.setColor(getResources().getColor(R.color.Yellow)) ;
                   paint.setAlpha(opacity);

                         // create canvas to draw on the bitmap
                    Canvas canvas = new Canvas(mutbit);
                    canvas.drawCircle(event.getX(),event.getY(), 10, paint);

                    im.setAdjustViewBounds(true);
                    im.setImageBitmap(mutbit);
                    dd[1]=im.getDrawable();
                    Bitmap aa=mutbit.copy(Bitmap.Config.ARGB_4444,false);//mutbit=bb[tabCount].copy(Bitmap.Config.ARGB_4444, true);
                    bb[1]=aa;
                    return true;
                }
             return false;
        }
Kara
  • 6,115
  • 16
  • 50
  • 57
yuva ツ
  • 3,707
  • 9
  • 50
  • 78

1 Answers1

1

Try this draw circle on Action down event.getAction()==MotionEvent.ACTION_UP to event.getAction() == MotionEvent.ACTION_DOWN

ShreeshaDas
  • 2,042
  • 2
  • 17
  • 36
  • is it like- ' if(event.getAction()==MotionEvent.ACTION_DOWN) ' . i tried this.its also not working – yuva ツ Feb 24 '13 at 09:42
  • same condition as that person want.i want it in my activity class. – yuva ツ Feb 24 '13 at 10:56
  • you are making costume view in Activity? – ShreeshaDas Feb 24 '13 at 11:09
  • How to do this.actually i'm very new to all this.i want to draw a circle on image which is opened and again save it. – yuva ツ Feb 24 '13 at 11:19
  • 1
    Try this http://stackoverflow.com/questions/4439456/how-to-create-a-simple-custom-view and http://stackoverflow.com/questions/14994621/eraser-is-not-called-when-button-is-pressed, http://www.youtube.com/watch?v=vOY2AxbnRyc – ShreeshaDas Feb 24 '13 at 11:22