希望图像在翻译动画中从 (YDelta) 到 (toYDelta) 时在中心显示几秒钟
Want image to be shown on center for few seconds while going from (YDelta) to (toYDelta) in Translate Animation
我正在创建带有动画的登录页面,例如 FB 登录。我希望我的徽标图像在中心显示几秒钟,同时从 Ydelta 到 Ydelta 进行动画处理。
代码:
animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.translate);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationEnd(Animation arg0) {
loginBox.setVisibility(View.VISIBLE);
Animation animFade = AnimationUtils.loadAnimation(MainActivity.this, R.anim.fade);
loginBox.startAnimation(animFade);
}
});
ImageView imgLogo = (ImageView) findViewById(R.id.imageView );
imgLogo.startAnimation(animation);
}
translate.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fillAfter="true">
<translate
android:fromYDelta="30%p"
android:toYDelta="0%p"
android:duration="1000" />
</set>
感谢任何类型的帮助!!
谢谢
您可以使用两种动画:
translate1.xml:
<translate
android:fromYDelta="0%"
android:toYDelta="50%"
android:duration="1000"
/>
translate2.xml:
<translate
android:fromYDelta="50%"
android:toYDelta="100%"
android:duration="1000"
android:startOffset="2000" />
用android:startOffset
来延迟动画。
moveToCenterAnim= AnimationUtils.loadAnimation(MainActivity.this, R.anim.translate1);
moveToCenter.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationEnd(Animation arg0) {
...
ImageView imgLogo = (ImageView) findViewById(R.id.imageView );
Animation moveOnAnim= AnimationUtils.loadAnimation(MainActivity.this, R.anim.translate2);
imgLogo.startAnimation(moveOnAnim);
}
});
ImageView imgLogo = (ImageView) findViewById(R.id.imageView );
imgLogo.startAnimation(moveToCenterAnim);
}
我正在创建带有动画的登录页面,例如 FB 登录。我希望我的徽标图像在中心显示几秒钟,同时从 Ydelta 到 Ydelta 进行动画处理。 代码:
animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.translate);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationEnd(Animation arg0) {
loginBox.setVisibility(View.VISIBLE);
Animation animFade = AnimationUtils.loadAnimation(MainActivity.this, R.anim.fade);
loginBox.startAnimation(animFade);
}
});
ImageView imgLogo = (ImageView) findViewById(R.id.imageView );
imgLogo.startAnimation(animation);
}
translate.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fillAfter="true">
<translate
android:fromYDelta="30%p"
android:toYDelta="0%p"
android:duration="1000" />
</set>
感谢任何类型的帮助!! 谢谢
您可以使用两种动画:
translate1.xml:
<translate
android:fromYDelta="0%"
android:toYDelta="50%"
android:duration="1000"
/>
translate2.xml:
<translate
android:fromYDelta="50%"
android:toYDelta="100%"
android:duration="1000"
android:startOffset="2000" />
用android:startOffset
来延迟动画。
moveToCenterAnim= AnimationUtils.loadAnimation(MainActivity.this, R.anim.translate1);
moveToCenter.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationEnd(Animation arg0) {
...
ImageView imgLogo = (ImageView) findViewById(R.id.imageView );
Animation moveOnAnim= AnimationUtils.loadAnimation(MainActivity.this, R.anim.translate2);
imgLogo.startAnimation(moveOnAnim);
}
});
ImageView imgLogo = (ImageView) findViewById(R.id.imageView );
imgLogo.startAnimation(moveToCenterAnim);
}