ngesh
ngesh

Reputation: 13501

LayoutTransition Class in NineOldAndroids..?

I want to animate add View as a "slide Down" and remove View as "slide Up" in a ViewGroup. So i used LayoutTransition.class but its not supported for minSdk 8. So i found this NineOldAndroids, and was wondering if i can achieve what i want using this.

Something like this,

LayoutTransition layoutTransition = new LayoutTransition();
        AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(getApplicationContext(),
                R.anim.slide);
        layoutTransition.setAnimator(LayoutTransition.APPEARING, set);

Upvotes: 2

Views: 745

Answers (2)

Raso
Raso

Reputation: 1

I also need to animate when adding a view without LayoutTransition. I have no idea when to start the animation so I use LayoutAnimationController to do :

     // A fake AlphaAnimation so that we can know how to start the animation of adding view
      Animation animation = new AlphaAnimation(0, 0);
        animation.setDuration(1);
        animation.setFillAfter(true);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
}

@Override public void onAnimationEnd(Animation animation) { // start the animation here startAddingViewAnimation(); } @Override public void onAnimationRepeat(Animation animation) { } }); ViewGroup viewroot = findViewById(R.id.viewroot); LayoutAnimationController layoutAnimationController = new LayoutAnimationController(animation); viewRoot.setLayoutAnimation(layoutAnimationController); viewRoot.addView(btn);

Set a LayoutAnimationController to notify me that the view was added and finished to draw. Then I can start the animation by nineoldanimator.

Upvotes: 0

mark.kedzierski
mark.kedzierski

Reputation: 663

Unfortunately NineOldAndroids does not support LayoutTransitions as it is not possible to implement in Gingerbread.

Upvotes: 3

Related Questions