title: Move ImageView relatively to another imageView's position- Android Studio
body: <p>I'm trying to make an ImageView follow another ImageView, by changing it's coordinates. My movement method is that:</p>
  
  <p>public void move(double zx, double zy) {</p>
  
  <pre><code>    if (zx &lt; a.getLeft()) {
  
          if (a.getLeft() - zx &gt; 0) {
  
              a.setLeft(a.getLeft() - 1);
  
          } else
  
              a.setLeft(a.getLeft()+1);
  
      }
      if (zx &gt; a.getLeft()) {
  
          if (a.getLeft() - zx &gt; 0) {
  
              a.setLeft(a.getLeft() - 1);
  
          } else
  
              a.setLeft(a.getLeft() - 1);
  
      }
  
      if (zy &gt; a.getTop()) {
  
          if (a.getTop() - zy &gt; 0) {
  
              a.setTop(a.getTop() - 1);
  
          } else
  
              a.setTop(a.getTop() + 1);;
  
      }
  
      if (zy &lt; a.getTop()) {
  
          if (a.getTop() - zy &gt; 0) {
  
              a.setTop(a.getTop() - 1);
  
          } else
  
              a.setTop(a.getTop() + 1);
  
      }
  
  }
  </code></pre>
  
  <p>OnCreate:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_fase);
      a = (ImageView)findViewById(R.id.a);
      b = (ImageView)findViewById(R.id.b);
  
      move(b.getLeft(), b.getTop());
  }
  </code></pre>
  
  <p>"a" and "b" are the ImageViews, and a should follow b. I declared both ImageViews correctly, and the method should work. Instead of it, the ImageView "a" keep in the same position since the application starts. What is wrong? Is the method move declared at the wrong place (onCreate) ? I also have tried to just set the vertical position of "a" in another part of the screen, for testing if it would work. But it didn't (and according to the logCat it's vertical position had changed). The tutorials I found about moving images are based on dragging them, but I haven't still found anything about another kind of movement, like this.</p>
  
  <p>There is my layout (activity_fase.xml) :</p>
  
  <p></p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  android:paddingBottom="@dimen/activity_vertical_margin"
  tools:context="thegame.app.Fase"
  android:background="@drawable/seapaint"&gt;
  
  
  &lt;ImageView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/b"
      android:layout_centerVertical="true"
      android:layout_centerHorizontal="true"
      android:src="@drawable/b"/&gt;
  
  &lt;ImageView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/a"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:src="@drawable/a"
      android:focusable="true"
      android:clickable="false"
      android:layout_marginBottom="79dp" /&gt;
  
  &lt;ImageView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/imageView2"
      android:layout_above="@+id/b"
      android:layout_alignLeft="@+id/a"
      android:layout_alignStart="@+id/key"
      android:layout_marginBottom="67dp"
      android:src="@drawable/key"
      android:layout_marginLeft="50dp"/&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceSmall"
      android:text="Small Text"
      android:id="@+id/points"
      android:layout_alignParentTop="true"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>I'm new on android developing, and I don't know the difference between relative layout and linear layout. </p>