Answer the question
In order to leave comments, you need to log in
Why does view become non-clickable after animation?
Good day.
I have a task to swap view in LinearLayout with movement animation.
This is how I do it.
item_view = box_contact_profile.getChildAt(position);
Animation animationUp = AnimationUtils.loadAnimation(getActivity(), R.anim.swap_view_up);
animationUp.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
Animation animationDown = AnimationUtils.loadAnimation(getActivity(), R.anim.swap_view_down);
box_contact_profile.getChildAt(position - 1).startAnimation(animationDown);
}
@Override
public void onAnimationEnd(Animation animation) {
View save_view = box_contact_profile.getChildAt(position);
box_contact_profile.removeViewAt(position);
v.setTag(position - 1);
box_contact_profile.addView(save_view, position - 1);
for (int i = position; i < box_contact_profile.getChildCount(); i++) {
save_view = box_contact_profile.getChildAt(position);
ImageButton but = (ImageButton) save_view.findViewById(R.id.but_menu_bloc_contact);
but.setTag(i);
}
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
item_view.startAnimation(animationUp);
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
>
<translate
android:fromYDelta="0%"
android:toYDelta="100%"
android:duration = "200">
</translate>
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
>
<translate
android:fromYDelta="0%"
android:toYDelta="-100%"
android:duration = "200"
>
</translate>
</set>
Answer the question
In order to leave comments, you need to log in
The problem is that the animation has parameters
android:fillBefore
android:fillAfter
If android:fillBefore = true, then all transformations with objects must be done before the animation starts, and if you do them at the end of the animation (in the onAnimationEnd listener), then the display of objects will return to its original state, but the objects themselves can change their location, as it was in my code.
And if android:fillAfter = true, then all transformations must be done after animation.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question