画面の中央から始まるImageViewをアニメーション化し、画面の上部から10ピクセル上に移動したいと思います。コードでこれをどのように達成できますか?
私が現在行っているのは、画面を別の画像に合わせて、このアニメーション画像をその上に少し配置することですが、高密度の大画面では、同じ距離を維持できないためです。代わりに、上から10px移動したいと思います。
どうすればこれを達成できますか?
これが私のコードです:
//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);