Example usage for android.view.animation TranslateAnimation TranslateAnimation

List of usage examples for android.view.animation TranslateAnimation TranslateAnimation

Introduction

In this page you can find the example usage for android.view.animation TranslateAnimation TranslateAnimation.

Prototype

public TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta) 

Source Link

Document

Constructor to use when building a TranslateAnimation from code

Usage

From source file:com.xmobileapp.rockplayer.RockPlayer.java

public void setListExpandedView() {

    try {//ww  w.  j a v a  2s.  c  om
        /*
         * Animate fading of the current playing layout
         */
        Rotate3dAnimation perspectiveFullLeft = new Rotate3dAnimation(0, 0, // X-axis rotation
                90, 90, // Y-axis rotation
                0, 0, // Z-axis rotation
                100, 100, // rotation center
                0.0f, // Z-depth
                false); //reverse movement
        perspectiveFullLeft.setFillAfter(true);
        perspectiveFullLeft.setDuration(1);
        currentPlayingLayout.startAnimation(perspectiveFullLeft);

        // hide parts of mainUI

        /*
         * Animate growth of the album navigator
         */
        int slideAmount = display.getWidth() - albumNavigatorList.getWidth();
        TranslateAnimation slideLeft = new TranslateAnimation(slideAmount, 0, 0, 0);
        slideLeft.setFillAfter(true);
        slideLeft.setDuration(400);
        albumNavigatorLayoutOuter.startAnimation(slideLeft);

        /*
         * Put album navigator full screen
         */
        RelativeLayout.LayoutParams params = (LayoutParams) albumNavigatorLayoutOuter.getLayoutParams();
        params.addRule(RelativeLayout.RIGHT_OF, 0);
        albumNavigatorLayoutOuter.setLayoutParams(params);
        //albumNavigatorLayout.setBackgroundColor(Color.WHITE);
        //            
        //            LayoutParams paramsList = (LayoutParams) albumNavigatorList.getLayoutParams();
        //            paramsList.width = display.getWidth();
        //            albumNavigatorList.setLayoutParams(paramsList);

        //         currentPlayingLayout.setVisibility(View.GONE);

        VIEW_STATE = LIST_EXPANDED_VIEW;
    } catch (Exception e) {
        e.printStackTrace();
    }

    return;

}

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  av a 2 s.  c  o m*/
    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);
}

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

static void animate_bottom_bar_down() {
    final FrameLayout a = (FrameLayout) Global_Navit_Object.findViewById(R.id.bottom_bar_slide);

    // System.out.println("FRAG:animate_bottom_bar_down:014");

    // set bottom end positon correctly??
    bottom_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px
            - Navit.bottom_bar_slider_shadow_px;

    final int move_by = (int) (bottom_y_margin_bottom_bar_touch - cur_y_margin_bottom_bar_touch);
    TranslateAnimation animation = new TranslateAnimation(0, 0, 0, move_by); //  new TranslateAnimation(xFrom,xTo, yFrom,yTo)
    animation.setDuration(bottom_bar_snap_duration); // animation duration
    animation.setFillAfter(true);/*from  ww w.  j a  v  a2  s  .  c om*/
    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) {
            // set bottom end positon correctly??
            bottom_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px
                    - Navit.bottom_bar_slider_shadow_px;

            cur_y_margin_bottom_bar_touch = bottom_y_margin_bottom_bar_touch;
            RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams();
            relativeParams.setMargins(0, (int) bottom_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);

            // remove roadbook fragment -----------
            try {
                if (road_book != null) {
                    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
                    // System.out.println("FRAG:dettach:002");
                    fragmentTransaction.detach(road_book);
                    fragmentTransaction.remove(road_book).commit();
                    road_book = null;
                }
            } catch (Exception ef) {
            }
            // remove roadbook fragment -----------

        }
    });
    a.startAnimation(animation);
}