title: resizing the imageView makes it change its place
body: <p>I am having a Relative layout with few images in it like this below.</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" &gt;
  
  
      &lt;ImageView
          android:id="@+id/image_2"
          android:layout_width="30dp"
          android:layout_height="30dp"
          android:layout_alignLeft="@+id/increase"
          android:layout_alignParentTop="true"
          android:layout_marginLeft="34dp"
          android:layout_marginTop="34dp"
          android:src="@drawable/ic_launcher" /&gt;
  
      &lt;ImageView
          android:id="@+id/image_1"
          android:layout_width="30dp"
          android:layout_height="30dp"
          android:layout_alignBottom="@+id/image_2"
          android:layout_marginBottom="14dp"
          android:layout_toRightOf="@+id/increase"
          android:src="@drawable/ic_launcher" /&gt;
  
      &lt;ImageView
          android:id="@+id/image_8"
          android:layout_width="30dp"
          android:layout_height="30dp"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true"
          android:src="@drawable/ic_launcher" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>and in my java file i need to perform a small task.
  When i click an image it's size should be increased.
  I tried this and it was working and this is my code </p>
  
  <pre><code>public class MainActivity extends Activity implements OnClickListener {
  
  View imageView;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      ImageView i1 = (ImageView ) findViewById(R.id.image_1);
      ImageView i2 = (ImageView ) findViewById(R.id.image_2);
               ImageView i3 = (ImageView ) findViewById(R.id.image_8);
              i1.setOnClickListener(this);
      i2.setOnClickListener(this);
      i3.setOnClickListener(this);
  }
  
  public void onClick(View arg0) {
      Log.v("clicked ", "clicked");
      imageView = arg0;
      Toast.makeText(this, "looking to resize the image ", 1).show();
      Toast.makeText(this, "clicked 2", 1).show();
  
      height = imageView.getHeight();
          width = imageView.getWidth();
      height += 50;
      width += 50;
      imageView.setLayoutParams(new RelativeLayout.LayoutParams(height, width));
  
  }   
  
  }
  </code></pre>
  
  <p>But i am facing a problem.
  when i click the image its position is changing.
  Consider these screen shots ..</p>
  
  <p>The below is the screen shot when the application is launched</p>
  
  <p><img src="https://i.stack.imgur.com/y4LlO.png" alt="enter image description here"></p>
  
  <p>and below is the screen shot when an image view is clicked.</p>
  
  <p><img src="https://i.stack.imgur.com/LJi0c.png" alt="enter image description here"></p>
  
  <p>Can anyone suggest me so that the image doesnt change its position 
  I can use something like using a grid view (if possible. but even i am trying to put some drag option to it. So can anyone suggest me please)</p>
  
  <p><strong>UPDATED CODE :</strong></p>
  
  <p>the onclick method is updated as below : </p>
  
  <pre><code>public void onClick(View arg0) {
      Log.v("clicked ", "clicked");
      imageView = arg0;
      Toast.makeText(this, "looking to resize the image ", 1).show();
      Toast.makeText(this, "clicked 2", 1).show();
  
      height = imageView.getHeight();
  width = imageView.getWidth();
      height += 50;
      width += 50;
      RelativeLayout.LayoutParams params = new
            RelativeLayout.LayoutParams(height, width);
  
      params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
      params.setMargins( 
                  imageView.getLeft()-30,imageView.getTop()-30,imageView.getRight()+30,
                 imageView.getBottom()+30);
      imageView.setLayoutParams(params);
  
  
  
  }
  </code></pre>