title: Android imageview move drag within the limit
body: <p>I have long been working the code for dragging the image within the relativelayout with all width and height wrap_content. When it comes to the execution, it shows the  blinking arrow image to set the y-position of the  imageview within the relative layout. Would you please tell me the way to construct the image drag vertically within the arbitrary limit . ? </p>
  
  <p>The below is my code  : </p>
  
  <pre><code>dragImage.setOnTouchListener(new OnTouchListener(){
                  //private int _xDelta;
                  private int _yDelta;
              @Override
              public boolean onTouch(View v, MotionEvent event) {
  
                  v.getParent().requestDisallowInterceptTouchEvent(true);
  
  
  
                  final float y = event.getY();
  
                  switch (event.getAction()) {
                  case MotionEvent.ACTION_DOWN:
                      //_yDelta = Y - lParams.topMargin;
                      mOldY2 = y;
                      break;
                  case MotionEvent.ACTION_UP:
                      mViewPager.setPagingEnabled(true);
                      break;
                  case MotionEvent.ACTION_POINTER_DOWN:
                      break;
                  case MotionEvent.ACTION_POINTER_UP:
                      break;
                  case MotionEvent.ACTION_MOVE:
                      btn4.setBackgroundResource(R.drawable.fbl02);
                      final float dy = y - mOldY2;
                      mNewY2 += dy;
                      mOldY2 = y;
                      System.out.println(mNewY2);                 
  
                      while(mNewY2 &gt; 224){
                          mNewY2 -= 224;
                      }
  
                      while(mNewY2 &lt; 157){
                          mNewY2 += 157;
                      }
  
  
                      if(mNewY2 &lt; 157 || mNewY2 &gt; 224)
                          break;
  
                      v.setTranslationY((int)mNewY2);
  
                      v.invalidate();
  
                      float power = (float) ( 51.5/67 -(0.2/67) * mNewY2) ;
                      System.out.println(power);
  
                      Float roundF = new Float( Math.round(power));
                      midBandStick = roundF;
                      btn4.setText(String.valueOf(midBandStick) );
                      //}
                      //break;
                  }
                  return true;
  
              }
  </code></pre>