如何执行上界点击在android系统在画布上绘制? [英] How to perform click on circles drawn on a canvas in android?

查看:114
本文介绍了如何执行上界点击在android系统在画布上绘制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个应用人脸检测,在此应用程序我必须通过眼睛和面部和用户的嘴附近画圈圈可以点击拖动圈子根据他的脸上dedetected设置相同的位置。因此,各界已经成功绘制在脸上,但我不能能够点击特定的圈子和整个脸zoomout选择继续前行。请建议我要对相同的解决方案。

I am developing a facedetection app, in this app I have to draw circles near by the eyes and mouth of the face and user can click to drag circles for setting position of the same according to the him on the dedetected face. So, all circles has been drawn successfully on the face but I can't able to click on the particular circle and move on throughout the face with zoomout option. Please suggest me for the right solution regarding the same.

先谢谢了。

推荐答案

下面是我用矩形的例子。看看你能不能调整code使用圆周代替。

Here is an example I used for rectangles. See if you can adjust the code to use circles instead.

@Override
public boolean onTouchEvent( MotionEvent event) {
     super.onTouchEvent(event);

        int x = (int)event.getX();
        int y = (int)event.getY();
        xStored = x; yStored=y;
        if (event.getAction()==MotionEvent.ACTION_UP){

       }else if(event.getAction()==MotionEvent.ACTION_DOWN){
           System.out.println("Touching down!");
               for(Rect rect : rectangles){
                    if(rect.contains(x,y)){
                        System.out.println("Touched Rectangle, start activity."+x+","+y);

                            invalidate();
                 }else{

                 }
               }


           }else if(event.getAction()==MotionEvent.ACTION_MOVE){

           }
          this.postInvalidate();
         return true;
      }

这篇关于如何执行上界点击在android系统在画布上绘制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆