Reputation: 1330
With the code below, the TextView
variable tvAppName
slides up successfully, but after 1,200 milliseconds the view goes back to its position. How can I fix the view after moving it?
Handler hd = new Handler();
hd.postDelayed(new Runnable() {
@Override
public void run() {
TranslateAnimation anim = new TranslateAnimation(0, 0, 100, 0);
anim.setDuration(500);
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
tvAppName.startAnimation(anim);
}
}, 1200);
}
Upvotes: 0
Views: 68
Reputation: 2352
From the documentation: You need use setFillAfter method.
anim.setFillAfter( true );
If fillAfter is true, the transformation that this animation performed will persist when it is finished
Hope it helps.
Upvotes: 1
Reputation: 220
You should use anim.setfillafter(true)
the transformation that this animation performed will persist when it is finished
If you did not use code below.you can Delete That
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
Upvotes: 0
Reputation: 5440
You should use NineOldAndroid library. This is a really good library. It will help you with a lot of animations.
Upvotes: 0