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(int fromXType, float fromXValue, int toXType, float toXValue, int fromYType,
        float fromYValue, int toYType, float toYValue) 

Source Link

Document

Constructor to use when building a TranslateAnimation from code

Usage

From source file:Main.java

public static Animation outToRightAnimation() {
    Animation outtoRight = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f);
    outtoRight.setDuration(250);/*from   w  w w  .  ja  v a  2 s .c om*/
    outtoRight.setInterpolator(new AccelerateInterpolator());
    return outtoRight;
}

From source file:Main.java

public static Animation inFromRightAnimation() {

    Animation inFromRight = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, +1.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f);
    inFromRight.setDuration(250);// ww  w  .  j  a  va 2 s . c o m
    inFromRight.setInterpolator(new AccelerateInterpolator());
    return inFromRight;
}

From source file:Main.java

public static void postAnimation(final View childLayout, int delay, final int duration) {
    int visibility = childLayout.getVisibility();
    if (visibility != View.VISIBLE) {
        return;/*from w  ww . j a  v a 2  s  . c  om*/
    }
    childLayout.setVisibility(View.INVISIBLE);
    childLayout.postDelayed(new Runnable() {
        @Override
        public void run() {
            childLayout.setVisibility(View.VISIBLE);
            AnimationSet animationSet = new AnimationSet(true);
            animationSet.setDuration(duration);
            animationSet.setInterpolator(new OvershootInterpolator(0.8f));
            int pivotXType = Animation.RELATIVE_TO_SELF;
            animationSet.addAnimation(
                    new TranslateAnimation(pivotXType, -1, pivotXType, 0, pivotXType, 0, pivotXType, 0));
            animationSet.addAnimation(new AlphaAnimation(0, 1));
            childLayout.startAnimation(animationSet);
        }
    }, delay);
}

From source file:Main.java

public static void postAnimationBottom(final View childLayout, int delay, final int duration) {
    int visibility = childLayout.getVisibility();
    if (visibility != View.VISIBLE) {
        return;//from w w w  .  ja  va 2s .co m
    }
    childLayout.setVisibility(View.INVISIBLE);
    childLayout.postDelayed(new Runnable() {
        @Override
        public void run() {
            childLayout.setVisibility(View.VISIBLE);
            AnimationSet animationSet = new AnimationSet(true);
            animationSet.setDuration(duration);
            animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
            int pivotXType = Animation.RELATIVE_TO_SELF;
            animationSet.addAnimation(
                    new TranslateAnimation(pivotXType, 0, pivotXType, 0, pivotXType, 1, pivotXType, 0));
            animationSet.addAnimation(new AlphaAnimation(0, 1));
            childLayout.startAnimation(animationSet);
        }
    }, delay);
}

From source file:com.example.demo_highlights.slidingmenu.fragment.PageFragment1.java

private LayoutAnimationController getListAnim() {
    AnimationSet set = new AnimationSet(true);
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(200);/*from w ww  .j  a  v  a  2s  .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(200);
    set.addAnimation(animation);

    Animation inAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1.0f,
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            0.0f);
    inAnimation.setDuration(200);
    inAnimation.setFillAfter(true);
    set.addAnimation(inAnimation);

    Animation outAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            0.0f);
    outAnimation.setDuration(200);
    outAnimation.setFillAfter(true);
    // 
    LayoutAnimationController inController = new LayoutAnimationController(inAnimation, 0.3f);
    // 
    LayoutAnimationController outController = new LayoutAnimationController(outAnimation, 0.3f);

    LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
    return controller;
}

From source file:com.aniruddhc.acemusic.player.WelcomeActivity.MusicFoldersFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mContext = getActivity().getApplicationContext();
    mApp = (Common) mContext;//from   w  w w .  ja v  a  2  s  .co m
    View rootView = (View) getActivity().getLayoutInflater().inflate(R.layout.fragment_welcome_screen_2, null);

    mFoldersLayout = (RelativeLayout) rootView.findViewById(R.id.folders_fragment_holder);
    if (mApp.getSharedPreferences().getInt("MUSIC_FOLDERS_SELECTION", 0) == 0) {
        mFoldersLayout.setVisibility(View.INVISIBLE);
        mFoldersLayout.setEnabled(false);
    } else {
        mFoldersLayout.setVisibility(View.VISIBLE);
        mFoldersLayout.setEnabled(true);
    }

    mSlideInAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            0.0f, Animation.RELATIVE_TO_SELF, 2.0f, Animation.RELATIVE_TO_SELF, 0.0f);

    mSlideInAnimation.setDuration(600);
    mSlideInAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    mSlideInAnimation.setAnimationListener(slideInListener);

    mSlideOutAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 2.0f);
    mSlideOutAnimation.setDuration(600);
    mSlideOutAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    mSlideOutAnimation.setAnimationListener(slideOutListener);

    mChildFragmentManager = this.getChildFragmentManager();
    mChildFragmentManager.beginTransaction()
            .add(R.id.folders_fragment_holder, getMusicFoldersSelectionFragment()).commit();

    mWelcomeHeader = (TextView) rootView.findViewById(R.id.welcome_header);
    mWelcomeHeader.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Light"));

    mMusicFoldersOptions = (RadioGroup) rootView.findViewById(R.id.music_library_welcome_radio_group);
    RadioButton getAllSongsRadioButton = (RadioButton) mMusicFoldersOptions
            .findViewById(R.id.get_all_songs_radio);
    RadioButton letMePickFoldersRadioButton = (RadioButton) mMusicFoldersOptions
            .findViewById(R.id.pick_folders_radio);

    getAllSongsRadioButton.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
    letMePickFoldersRadioButton.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));

    mMusicFoldersOptions.setOnCheckedChangeListener(onCheckedChangeListener);
    return rootView;
}

From source file:com.jiubai.jiubaijz.zxing.activity.CaptureActivity.java

private void initView() {
    Window window = getWindow();/*  w ww  .j av  a2 s  .  c o m*/
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    setContentView(R.layout.activity_capture);

    ButterKnife.bind(this);

    mInactivityTimer = new InactivityTimer(this);
    mBeepManager = new BeepManager(this);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.9f);
    animation.setDuration(4500);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    mScanLineImageView.startAnimation(animation);
}

From source file:eu.thedarken.rootvalidator.ValidatorFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    AnimationSet set = new AnimationSet(true);
    Animation fadeIn = new AlphaAnimation(0.0f, 1.0f);
    fadeIn.setDuration(350);/*  ww  w .  j a  v  a 2 s. c o  m*/
    set.addAnimation(fadeIn);
    Animation dropDown = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF,
            0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    dropDown.setDuration(400);
    set.addAnimation(dropDown);
    LayoutAnimationController controller = new LayoutAnimationController(set, 0.2f);
    mRecyclerView.setLayoutAnimation(controller);

    mFab.attachToRecyclerView(mRecyclerView);
    mFab.setVisibility(View.INVISIBLE);
    mEmptyStartView.setVisibility(View.GONE);
    mEmptyWorkingView.setVisibility(View.GONE);
    mListContainer.addView(mEmptyStartView);
    mListContainer.addView(mEmptyWorkingView);
    mRecyclerView.setEmptyView(mEmptyStartView);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
}

From source file:com.example.fragment.ScreenSlidePageFragment.java

public void startAnimation() {
    // SELECT LAYER
    ScrollView relate = (ScrollView) mRootView.findViewById(R.id.content);
    //       relate.setVisibility(View.VISIBLE);

    AnimationSet set = new AnimationSet(true);
    set.setAnimationListener(this);

    TranslateAnimation translate;/* w w w  .j a  va 2  s  .  com*/
    float toX = -8.0f / 100.0f;//0.0f;
    float fromX = 0.0f;//-8.0f / 100.0f;
    float toY = 0.0f;
    float fromY = 29.0f / 100.0f;
    translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX,
            Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY);
    translate.setDuration(2000);
    translate.setInterpolator(new AccelerateInterpolator());

    set.addAnimation(translate);
    set.setFillBefore(true);
    //          set.setFillBefore(false);
    //         set.setFillAfter(false);
    set.setFillAfter(true);

    relate.startAnimation(set);
}

From source file:com.chiemy.zxing.activity.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Window window = getWindow();/*from w  w  w  .  j ava 2  s  .  c  o  m*/
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(getLayoutId());

    scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    scanLine = (ImageView) findViewById(R.id.capture_scan_line);

    //inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);

    getWindow().getDecorView().post(new Runnable() {
        @Override
        public void run() {
            TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
                    Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
                    Animation.RELATIVE_TO_PARENT, 0.9f);
            animation.setDuration(4500);
            animation.setRepeatCount(-1);
            animation.setRepeatMode(Animation.RESTART);
            scanLine.startAnimation(animation);
        }
    });

    redecodeHandler = new Handler();
    redecodeRunnable = new RedecodeRunnable(this);
}