title: Find distance of drag event in android
body: <p>I have two <code>textView</code> elements, <code>android:id="@+id/num1"</code> and <code>android:id="@+id/num2"</code>. I would like the user to drag from <code>num1</code> to <code>num2</code>, and I would like to find the distance that they covered in the drag. In order to do so, I am trying to use an <code>onDragListener</code>, as shown below in my <code>.java</code> file. However, I am not sure how to use the <code>onDragListener</code> to find the distance dragged, I have looked into <code>ACTION_DRAG_STARTED</code> and <code>ACTION_DRAG_EXITED</code>, but I can't manipulate those to what I need. If anyone can figure out how to do this, your help would be much appreciated!</p>
  
  <p>The links I was using for drag Listeners
  <a href="http://developer.android.com/reference/android/view/View.OnDragListener.html" rel="nofollow">http://developer.android.com/reference/android/view/View.OnDragListener.html</a>
  <a href="http://developer.android.com/guide/topics/ui/drag-drop.html" rel="nofollow">http://developer.android.com/guide/topics/ui/drag-drop.html</a></p>
  
  <p><code>.java</code> file</p>
  
  <pre><code>public class MainActivity extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
  
          final View dragLayout = findViewById(R.id.dragLayout);        
          final TextView num1 = (TextView)findViewById(R.id.num1);
          final TextView num2 = (TextView)findViewById(R.id.num2);
  
          dragLayout.setOnDragListener(new View.OnDragListener() {
              @Override
              public boolean onDrag(View v, DragEvent event) {
  
              //Do something here with the drag event
  
              return true;
          }
      });
  }   
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
              // Inflate the menu; this adds items to the action bar if it is present.
              getMenuInflater().inflate(R.menu.main, menu);
              return true;
      }
  
  }
  </code></pre>
  
  <p>Thanks in advance</p>