user1248568
user1248568

Reputation: 621

Update layout after animation

Using animation I expand ImageView, but after scaling this overlaps other views. Is there any way to update layout properties, that I defined in activity xml file? I.e. I have some properties like layout_toRightOf that I want to apply after animation.

There is my code:

Animation:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" 
        android:fillAfter="true"
        android:fillEnabled="true">
    <scale
        android:duration="500"
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="2.0"
        android:toYScale="2.0" />

</set>

Applying animation:

    Animation shrinkAnimation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.shrink_animation);
    someView.startAnimation(shrinkAnimation);

Upvotes: 1

Views: 668

Answers (1)

MAC
MAC

Reputation: 15847

shrinkAnimation.setAnimationListener(new Animation.AnimationListener(){
    @Override
    public void onAnimationStart(Animation arg0) {
    }           
    @Override
    public void onAnimationRepeat(Animation arg0) {
    }           
    @Override
    public void onAnimationEnd(Animation arg0) {
       // Update your View here...
    }
});

Upvotes: 1

Related Questions