title: Android moving Image view to center of the screen
body: <p>I have one button and one image view at the bottom of my screen . when the button is clicked i want to move the image view to center of my screen. i'm trying with the following code . i'm not getting correctly. please help me.</p>
  
  <p>my.java file</p>
  
  <pre><code>      button.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              imageview= (ImageView)findViewById(R.id.imageView1);
              DisplayMetrics metrics = new DisplayMetrics();
              getWindowManager().getDefaultDisplay().getMetrics(metrics);
  
          float   x=metrics.heightPixels/2;
          float   y=metrics.widthPixels/2;
           TranslateAnimation anim = new TranslateAnimation( 0, x , 0, y);
           anim.setDuration(1000);
           anim.setFillAfter( true );
            imageview.startAnimation(anim);
  
          }
      });
  </code></pre>