- Playing DISAPPEARING and APPEARING layout animation
- public void onClick(View v) {
- if (componentOneVisible) {
- componentOne.setVisibility(View.GONE);
- componentTwo.setVisibility(View.VISIBLE);
- } else {
- componentTwo.setVisibility(View.GONE);
- componentOne.setVisibility(View.VISIBLE);
- }
- componentOneVisible = !componentOneVisible;
- }
- final ObjectAnimator testIn = ObjectAnimator.ofPropertyValuesHolder(
- componentContainer,
- PropertyValuesHolder.ofFloat("scaleX", 0, 1f),
- PropertyValuesHolder.ofFloat("scaleY", 0, 1f),
- PropertyValuesHolder.ofFloat("alpha", 0f, 1f));
- testIn.addListener(new AnimatorListenerAdapter() {
- public void onAnimationEnd(Animator anim) {
- View view = (View) ((ObjectAnimator) anim).getTarget();
- view.setScaleX(1f);
- view.setScaleY(1f);
- view.setAlpha(1f);
- }
- });
- testIn.setDuration(3000);
- final ObjectAnimator testOut = ObjectAnimator.ofPropertyValuesHolder(
- componentContainer,
- PropertyValuesHolder.ofFloat("scaleX", 1f, 0),
- PropertyValuesHolder.ofFloat("scaleY", 1f, 0),
- PropertyValuesHolder.ofFloat("alpha", 1, 0f));
- testOut.setDuration(3000);
- testOut.addListener(new AnimatorListenerAdapter() {
- public void onAnimationEnd(Animator anim) {
- View view = (View) ((ObjectAnimator) anim).getTarget();
- view.setScaleX(0f);
- view.setScaleY(0f);
- view.setAlpha(0f);
- }
- });
- mTransitioner.setAnimator(LayoutTransition.APPEARING, testIn);
- mTransitioner.setAnimator(LayoutTransition.DISAPPEARING, testOut);
- mTransitioner.setDuration(5000);
- mTransitioner.setDuration(LayoutTransition.APPEARING, 3000);
- mTransitioner.setDuration(LayoutTransition.DISAPPEARING, 3000);
- mTransitioner = new LayoutTransition();
- componentContainer.setLayoutTransition(mTransitioner);