Example usage for android.widget FrameLayout startAnimation

List of usage examples for android.widget FrameLayout startAnimation

Introduction

In this page you can find the example usage for android.widget FrameLayout startAnimation.

Prototype

public void startAnimation(Animation animation) 

Source Link

Document

Start the specified animation now.

Usage

From source file:com.zoffcc.applications.zanavi.Navit.java

void animate_bottom_bar_up() {
    final FrameLayout a = (FrameLayout) findViewById(R.id.bottom_bar_slide);
    TranslateAnimation animation = new TranslateAnimation(0, 0, 0, -cur_y_margin_bottom_bar_touch);
    animation.setDuration(bottom_bar_snap_duration); // animation duration
    animation.setFillAfter(true);// ww w  .  j ava2s  .com
    animation.setFillEnabled(true);
    animation.setRepeatCount(0); // animation repeat count
    animation.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            cur_y_margin_bottom_bar_touch = 0;
            RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams();
            relativeParams.setMargins(0, (int) cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
            a.setLayoutParams(relativeParams);
            a.requestLayout();

            TranslateAnimation anim = new TranslateAnimation(0, 0, 0, 0);
            anim.setFillAfter(true);
            anim.setFillEnabled(true);
            anim.setDuration(1);
            a.startAnimation(anim);
        }
    });
    a.startAnimation(animation);
}