Answer the question
In order to leave comments, you need to log in
Android. How to make the element not come back after the animation?
There is an authorization form. In the login and password fields there is a TextView with the login and password entries, respectively, when I click on the EditText, I want to raise them above the fields using animation, but for some reason they come back after the animation ends. What to do?
<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="-30"
android:toYDelta="0"
android:duration="500">
</translate>
public void anim(View v) {
Animation anim = AnimationUtils.loadAnimation(this, R.anim.up_login_and_password);
TextView text;
((EditText) v).setCursorVisible(true);
if (v.getId() == R.id.login) {
text = (TextView) findViewById(R.id.loginView);
if (!isPressLogin) {
isPressLogin = true;
text.startAnimation(anim);
}
}
else {
text = (TextView) findViewById(R.id.passwordView);
if (!isPressPassword) {
isPressPassword = true;
text.startAnimation(anim);
}
}
}
Answer the question
In order to leave comments, you need to log in
Answer:
text.animate()
.setDuration(500)
.translationY(-50)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
text.setTranslationY(-50);//Здесь оставляем изменения после конца анимации
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question