title: imageview does not move on touch event android
body: <p>MY imageview does not move when ontouch event is called...Though I can see ACTION_UP and ACTION_MOVE happening from the log traces.</p>
  
  <p>Here is my code:-</p>
  
  <pre><code>public boolean onTouch(View v, MotionEvent motion) {
  
  
  
       float dy ;
       float dx;
       double r = 0;
       float angle = 0;
  
       switch(v.getId())
       {
          case R.id.arrow:
              switch(motion.getActionMasked())
              {
                  case MotionEvent.ACTION_MOVE:
                      Log.w(this.getClass().getName(),"In MOTION MOVE");
                      mX1 = motion.getX();
                      mY1 = motion.getY();
                      break;
  
                 case MotionEvent.ACTION_UP:
  
                    Log.w(this.getClass().getName(),"In MOTION UP");
                    mX2 = motion.getX();
                    mY2 = motion.getY();
                  dy = -( mY2-mY1);
                  dx = -(mX2-mX1);
                  r = Math.atan2(dy, dx);
                     angle = (int)Math.toDegrees(r);
                     updateRotation(angle);
                     break;
  
                 default:
                     break;
              }
  
              Log.d(this.getClass().getName(), "Value of angle in ontouch: " + Double.toString(angle));
  
              break;
  
          default:
              break;
       }
      return true;
  }
  </code></pre>
  
  <p>Basically I am trying to calculate the angular displacement when user touches the imageview and changes its position.</p>
  
  <p>======================================
  Edit:- Below is my update rotation function:-</p>
  
  <pre><code>public void updateRotation(double angle)
  
  {
  
      Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.arrow);
      int w = bitmap.getWidth();
      int h = bitmap.getHeight();
      String filePath = null;
      Matrix mtx = new Matrix();
  
      Log.d(this.getClass().getName(), "Value: " + Double.toString(angle));
  
      if(angle &gt; 90)
          angle = 90;
      mtx.postRotate((float) angle);
  
      bitmap = Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, true);
      Drawable draw =new BitmapDrawable(bitmap);
  
  
      mImageView.setBackgroundDrawable(draw);
      }
  </code></pre>
  
  <p>=========================================================</p>
  
  <p>Edit 2: Modified function</p>
  
  <pre><code>public boolean onTouch(View v, MotionEvent motion) {
  
  
  
       float dy ;
       float dx;
       double r = 0;
  
  
       switch(v.getId())
       {
          case R.id.arrow:
              switch(motion.getActionMasked())
              {
              case MotionEvent.ACTION_DOWN:
                  mX1 = motion.getX();
                  mY1 = motion.getY();
                  break;
  
                  case MotionEvent.ACTION_MOVE:
                      Log.w(this.getClass().getName(),"In MOTION MOVE");
                      mX1 = motion.getX();
                      mY1 = motion.getY();
                      break;
  
                 case MotionEvent.ACTION_UP:
  
                    Log.w(this.getClass().getName(),"In MOTION UP");
                    mX2 = motion.getX();
                    mY2 = motion.getY();
                  dy = -( mY2-mY1);
                  dx = -(mX2-mX1);
                  r = Math.atan2(dy, dx);
                     mAngle = (int)Math.toDegrees(r);
                     updateRotation();
                     break;
  
                 default:
                     break;
              }
  
              Log.d(this.getClass().getName(), "Value of angle in ontouch: " + Float.toString(mAngle));
  
              break;
  
          default:
              break;
       }
      return true;
  }
  </code></pre>
  
  <p>=============================================</p>
  
  <p>Edit 3:- Strange thing is that if i modify my onTouch event and perform all the calculations in ACTION_MOVE the imageview responds for each touch event, but this is not what I want as I cannot do the proper angluar rotation in ACTION_MOVE event</p>