3

大家。我从 XY 的乞求点用函数 Motion Event 在 SurfaceView 的顶部绘制了一个矩形。我想知道绘制矩形后如何拉它的侧面?

我的代码:

        protected void onDraw(Canvas canvas) {

         if(drawing){

             canvas.drawRect(Var.Numb3,Var.Numb4,Var.Numb,Var.Numb2, paint);

         }
        }

        @Override
        public boolean onTouchEvent(MotionEvent event) {


         int action = event.getAction();
         if (action==MotionEvent.ACTION_MOVE){
          float x = event.getX();
          float y = event.getY();
          Var.Numb  = Var.X ;
          Var.Numb2 = Var.Y ;
          Var.Numb3 = (int) x;
          Var.Numb4 = (int) y ;


         }
         else if (action==MotionEvent.ACTION_DOWN){
          Var.X = (int) event.getX();
          Var.Y = (int) event.getY();



          drawing = true;
         }
         else if (action==MotionEvent.ACTION_UP){
          drawing = true;




         }
         invalidate();
         return true;
        }

        }
4

0 回答 0