title: Android - TranslateAnimation from middle to top
body: <p>I want to animate an ImageView which starts at the center of the screen, and move it up 10 px below the top of the screen. How can I achieve this in code?</p>
  
  <p>What I'm currently doing, is that I'm getting the screen coords upon another image, and place this animation image a bit on top of that, but in large screens with high density, it don't keep the same distance, so instead I want to move it 10px from the top.</p>
  
  <p>How can I achieve this?</p>
  
  <p>Here's my code:</p>
  
  <pre><code>//calculate where to put the logo in y-axis depending on screen size
              int coords[] = {0,0};
              logoImageFixed.getLocationOnScreen(coords);
              int y = coords[1];
              int imgFixedHeight = logoImageFixed.getHeight();
              Log.d("daim","height: "+imgFixedHeight);
              float pointY = -(y + 3*imgFixedHeight);
  
              Animation a = new LogoAnimation(0.0f, 0.0f, 0.0f, pointY);
              a.setFillAfter(true);
              a.setDuration(600);
              a.setAnimationListener(new AnimationListener() {
                  @Override
                  public void onAnimationStart(Animation animation) {}
                  @Override
                  public void onAnimationRepeat(Animation animation) {}
                  @Override
                  public void onAnimationEnd(Animation animation) {
                      logoAnimated = true;
                  }
              });
              logoImage.startAnimation(a);
  </code></pre>