title: Move an image dynamically in android
body: <p>This is the oncreate from my application.</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  
       getWindow().setFormat(PixelFormat.UNKNOWN);
      surfaceView = (SurfaceView)findViewById(R.id.camerapreview);
      surfaceHolder = surfaceView.getHolder();
      surfaceHolder.addCallback(this);
      surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  
      controlInflater = LayoutInflater.from(getBaseContext());
      viewControl = controlInflater.inflate(R.layout.control, null);
      image =(ImageView) viewControl.findViewById(R.id.img);
      LayoutParams layoutParamsControl 
          = new LayoutParams(LayoutParams.FILL_PARENT, 
          LayoutParams.FILL_PARENT);
      this.addContentView(viewControl, layoutParamsControl);
  
  }
  </code></pre>
  
  <p>control.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:gravity="center"
          &gt;
  &lt;ImageView
      android:id="@+id/img"  
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/ic_launcher"
      /&gt;
  
   &lt;Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/button"
  /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>How can I move this image on a button click.
  Actually i want to transalate this image from the current pixel position to another.</p>
  
  <p>I tried this on the button click.</p>
  
  <pre><code> b =(Button)findViewById(R.id.button);
          b.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) { 
                  System.out.println("Button clicked");
                  TranslateAnimation anim = new TranslateAnimation(0,0,200,200);              
                  anim.setDuration(2000);
                  image.setAnimation(anim); 
              }
          });
  </code></pre>
  
  <p>but now the image will disappear for two seconds. What am I doing wrong.
  please any one help.
  Actually i want to move the image on accelerometer change.</p>