【问题标题】:ontouch in android: getting X and Y coordinates and drawing circle on that pointandroid中的ontouch:获取X和Y坐标并在该点上绘制圆
【发布时间】:2014-01-31 12:07:12
【问题描述】:

在我的屏幕触摸应用程序中,我正在获取坐标(x.y), 在那个位置之后,我正在画一个圆圈。但是当我在那个位置画一个圆圈时。它总是在某些 pt.s 上的图像的左上角画一个圆圈。我不明白为什么会这样正在发生。请帮帮我。

        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;
        }

【问题讨论】:

    标签: android android-canvas draw ontouchlistener


    【解决方案1】:

    试试这个 在 Action down 上画圈 event.getAction()==MotionEvent.ACTION_UPevent.getAction() == MotionEvent.ACTION_DOWN

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-17
    相关资源
    最近更新 更多