how to know imageView position then moving
<p>i want to learning ImageView,,,,,</p>

<p>I have one picture and I set up in a lot of imageview</p>

<p>this is my xml file</p>

<pre><code>&lt;RelativeLayout xmlns:tools="http://schemas.android.com/tools"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="clip_vertical" &gt;

        &lt;ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="12dp"
            android:src="@drawable/x" /&gt;

        &lt;ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/imageView1"
            android:layout_toRightOf="@+id/imageView1"
            android:src="@drawable/x" /&gt;

        &lt;ImageView
            android:id="@+id/imageView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/imageView2"
            android:layout_toRightOf="@+id/imageView2"
            android:src="@drawable/x" /&gt;

    &lt;/RelativeLayout&gt;
</code></pre>

<p>this is my code</p>

<pre><code>    public class MainActivity extends Activity {

        boolean t=true;

        ImageView imageView1,imageView2,imageView3;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
             getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                     WindowManager.LayoutParams.FLAG_FULLSCREEN); 

            setContentView(R.layout.activity_main);
            imageView1 = (ImageView)findViewById(R.id.imageView1);
            imageView2 = (ImageView)findViewById(R.id.imageView2);
            imageView3 = (ImageView)findViewById(R.id.imageView3);


            imageView1.setOnTouchListener(new OnTouchListener() {

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    RelativeLayout.LayoutParams mParams = (RelativeLayout.LayoutParams) imageView1.getLayoutParams();
                    if (t){
                        mParams.leftMargin = 48;
                        t=false;
                    }else{
                        mParams.leftMargin = 5;
                        t=true;
                    }
                    imageView1.setLayoutParams(mParams);
                    return false;
                }
              });

            imageView2.setOnTouchListener(new OnTouchListener() {

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    RelativeLayout.LayoutParams mParams = (RelativeLayout.LayoutParams) imageView2.getLayoutParams();
                    if (t){
                        mParams.leftMargin = 42;
                        t=false;
                    }else{
                        mParams.leftMargin = 0;
                        t=true;
                    }
                    imageView2.setLayoutParams(mParams);
                    return false;
                }
              });

            imageView3.setOnTouchListener(new OnTouchListener() {

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    RelativeLayout.LayoutParams mParams = (RelativeLayout.LayoutParams) imageView3.getLayoutParams();
                    if (t){
                        mParams.leftMargin = 42;
                        t=false;
                    }else{
                        mParams.leftMargin = 0;
                        t=true;
                    }
                    imageView3.setLayoutParams(mParams);
                    return false;
                }
              });



        }
    }
</code></pre>

<ol>
<li>if <strong>imageView3</strong> moving to <strong>right</strong>, <strong>imageview3</strong> position + 42.</li>
<li>if <strong>imageView2</strong> moving to <strong>right</strong>, <strong>imageView2</strong> set to left
<strong>imageView3</strong> then position <strong>imageView3</strong> stay on +42.</li>
<li>if <strong>imageView1</strong> moving to <strong>right</strong>, <strong>imageView1</strong> set to left
<strong>imageView2</strong>, then <strong>imageView2</strong> stay on position <strong>right</strong> to <strong>imageView3</strong>.(number 2)</li>
<li>if <strong>imageView3</strong> moving to <strong>left</strong> then <strong>imageView1,imageView2</strong>
and <strong>imageView3</strong> moving to left = 0.(back to my position on xml).</li>
</ol>

<hr>

<ol>
<li>if <strong>imageView2</strong> moving to <strong>right</strong>, then <strong>imageView2</strong> and
<strong>imageView3</strong> moving to right +42.</li>
<li>if <strong>imageView1</strong> moving to <strong>right</strong>, then <strong>imageView1</strong>,
<strong>ImageView2</strong> and <strong>imageView3</strong> to right +42.</li>
<li>if <strong>imageView2</strong> moving to <strong>left</strong>, <strong>imageView1</strong> and
<strong>imageView2</strong> go to left = 0. then <strong>imageView3</strong> stay on position +42.</li>
</ol>

<p>and so on</p>

<hr>

<p>how to make the application according to my logic by changing the code listed above?</p>
