Example usage for android.view ViewGroup setLayoutAnimation

List of usage examples for android.view ViewGroup setLayoutAnimation

Introduction

In this page you can find the example usage for android.view ViewGroup setLayoutAnimation.

Prototype

public void setLayoutAnimation(LayoutAnimationController controller) 

Source Link

Document

Sets the layout animation controller used to animate the group's children after the first layout.

Usage

From source file:Main.java

/** load a layout animation sequence from xml */
public static void setLayoutAnimation2(ViewGroup panel, Context ctx) {

    LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(ctx, R.anim.slide_in_left);

    panel.setLayoutAnimation(controller);

}

From source file:Main.java

/**
 * Assert run an AbsListView with LayoutAnimationController successfully.
 * @param instrumentation/*from   w w  w . j av  a2 s . c om*/
 * @param view
 * @param controller
 * @param duration
 * @throws InterruptedException
 */
public static void assertRunController(final Instrumentation instrumentation, final ViewGroup view,
        final LayoutAnimationController controller, final long duration) throws InterruptedException {

    instrumentation.runOnMainSync(new Runnable() {
        public void run() {
            view.setLayoutAnimation(controller);
            view.requestLayout();
        }
    });

    // LayoutAnimationController.isDone() always returns true, it's no use for stopping
    // the running, so just using sleeping fixed time instead. we reported issue 1799434 for it.
    Thread.sleep(duration + TIMEOUT_DELTA);
}

From source file:Main.java

public static void makeViewGroupAnimation(ViewGroup viewGroup) {
    AnimationSet set = new AnimationSet(true);

    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(50);/*from   w w w  .j  a va  2 s.  c  o m*/
    set.addAnimation(animation);

    animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    animation.setDuration(150);
    set.addAnimation(animation);

    LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
    viewGroup.setLayoutAnimation(controller);
}

From source file:com.android.contacts.list.MultiSelectContactsListFragment.java

protected void setLayoutAnimation(final ViewGroup view, int animationId) {
    if (view == null) {
        return;//from w  ww  .j a  v  a2  s .c  o m
    }
    view.setLayoutAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            view.setLayoutAnimation(null);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    view.setLayoutAnimation(AnimationUtils.loadLayoutAnimation(getActivity(), animationId));
}