Java Code Examples for android.view.animation.TranslateAnimation#RELATIVE_TO_SELF

The following examples show how to use android.view.animation.TranslateAnimation#RELATIVE_TO_SELF . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Adapter_Foods.java    From FoodOrdering with Apache License 2.0 6 votes vote down vote up
/**
 * 显示减号的动画
 */
private Animation getShowAnimation() {
    AnimationSet set = new AnimationSet(true);
    RotateAnimation rotate = new RotateAnimation(0, 720, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    set.addAnimation(rotate);
    TranslateAnimation translate = new TranslateAnimation(
            TranslateAnimation.RELATIVE_TO_SELF, 2f
            , TranslateAnimation.RELATIVE_TO_SELF, 0
            , TranslateAnimation.RELATIVE_TO_SELF, 0
            , TranslateAnimation.RELATIVE_TO_SELF, 0);
    set.addAnimation(translate);
    AlphaAnimation alpha = new AlphaAnimation(0, 1);
    set.addAnimation(alpha);
    set.setDuration(500);
    return set;
}
 
Example 2
Source File: Adapter_Foods.java    From FoodOrdering with Apache License 2.0 6 votes vote down vote up
/**
 * 隐藏减号的动画
 */
private Animation getHiddenAnimation() {
    AnimationSet set = new AnimationSet(true);
    RotateAnimation rotate = new RotateAnimation(0, 720, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    set.addAnimation(rotate);
    TranslateAnimation translate = new TranslateAnimation(
            TranslateAnimation.RELATIVE_TO_SELF, 0
            , TranslateAnimation.RELATIVE_TO_SELF, 2f
            , TranslateAnimation.RELATIVE_TO_SELF, 0
            , TranslateAnimation.RELATIVE_TO_SELF, 0);
    set.addAnimation(translate);
    AlphaAnimation alpha = new AlphaAnimation(1, 0);
    set.addAnimation(alpha);
    set.setDuration(500);
    return set;
}
 
Example 3
Source File: MainMenuMgr.java    From android_tv_metro with Apache License 2.0 6 votes vote down vote up
private void intLayoutAnim()
{
    Animation slideIn = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF, -1, TranslateAnimation.ABSOLUTE, 0,
            TranslateAnimation.ABSOLUTE, 0, TranslateAnimation.ABSOLUTE, 0);
    slideIn.setDuration(KAnimTimeShort);
    mAnimIn = new LayoutAnimationController(slideIn, LayoutAnimDelay);

    Animation slideOut = new TranslateAnimation(TranslateAnimation.ABSOLUTE, 0, TranslateAnimation.RELATIVE_TO_SELF, -1,
             TranslateAnimation.ABSOLUTE, 0, TranslateAnimation.ABSOLUTE, 0);
    slideOut.setDuration(KAnimTimeShort);

    slideOut.setFillAfter(true);
    mAnimOut = new LayoutAnimationController(slideOut, LayoutAnimDelay);
    mAnimOut.setOrder(LayoutAnimationController.ORDER_REVERSE);

    mainMenu.setLayoutAnimation(mAnimIn);
    mHideShowListener = new HideShowListener();
    mainMenu.setLayoutAnimationListener(mHideShowListener);

    mReady.autoSetVal(true, AnimationBlockTimer);
}
 
Example 4
Source File: HomeScreenActivity.java    From Gazetti_Newspaper_Reader with MIT License 6 votes vote down vote up
private AnimationSet getEntryAnimation(int inAnimationDuration) {
    //In
    AnimationSet mInAnimationSet = new AnimationSet(false);

    TranslateAnimation mSlideInAnimation = new TranslateAnimation(
            TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
            TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
            TranslateAnimation.RELATIVE_TO_SELF, -1.0f,
            TranslateAnimation.RELATIVE_TO_SELF, 0.0f);
    mSlideInAnimation.setFillAfter(true);

    AlphaAnimation mFadeInAnimation = new AlphaAnimation(0.0f, 1.0f);
    mFadeInAnimation.setFillAfter(true);

    mInAnimationSet.addAnimation(mSlideInAnimation);
    mInAnimationSet.addAnimation(mFadeInAnimation);

    mInAnimationSet.setDuration(inAnimationDuration);

    return mInAnimationSet;

}
 
Example 5
Source File: ActionSheet.java    From quickhybrid-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Animation createTranslationOutAnimation() {
    int type = TranslateAnimation.RELATIVE_TO_SELF;
    TranslateAnimation an = new TranslateAnimation(type, 0, type, 0, type, 0, type, 1);
    an.setDuration(TRANSLATE_DURATION);
    an.setFillAfter(true);
    return an;
}
 
Example 6
Source File: MainActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
private void startAnimation(){

        TranslateAnimation upUp = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF,0,TranslateAnimation.RELATIVE_TO_SELF,0,
                TranslateAnimation.RELATIVE_TO_SELF,0,TranslateAnimation.RELATIVE_TO_SELF,-1);
        upUp.setDuration(1000);
        TranslateAnimation upDown = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF,0,TranslateAnimation.RELATIVE_TO_SELF,0,
                TranslateAnimation.RELATIVE_TO_SELF,0,TranslateAnimation.RELATIVE_TO_SELF,1);
        upDown.setDuration(1000);
        upDown.setStartOffset(1000);

        //组合动画
        AnimationSet upSet = new AnimationSet(false);
        //将上面的动画添加到组合动画
        upSet.addAnimation(upUp);
        upSet.addAnimation(upDown);
        //控件开启动画
        iv_up.startAnimation(upSet);


        TranslateAnimation downDown = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF,0,TranslateAnimation.RELATIVE_TO_SELF,0,
                TranslateAnimation.RELATIVE_TO_SELF,0,TranslateAnimation.RELATIVE_TO_SELF,1);
        downDown.setDuration(1000);
        TranslateAnimation downUp = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF,0,TranslateAnimation.RELATIVE_TO_SELF,0,
                TranslateAnimation.RELATIVE_TO_SELF,0,TranslateAnimation.RELATIVE_TO_SELF,-1);
        downUp.setDuration(1000);
        downUp.setStartOffset(1000);

        AnimationSet downSet = new AnimationSet(false);
        downSet.addAnimation(downDown);
        downSet.addAnimation(downUp);

        iv_down.startAnimation(downSet);





    }
 
Example 7
Source File: ActionSheet.java    From android-ActionSheet with MIT License 5 votes vote down vote up
private Animation createTranslationInAnimation() {
    int type = TranslateAnimation.RELATIVE_TO_SELF;
    TranslateAnimation an = new TranslateAnimation(type, 0, type, 0, type,
            1, type, 0);
    an.setDuration(TRANSLATE_DURATION);
    return an;
}
 
Example 8
Source File: ActionSheet.java    From android-ActionSheet with MIT License 5 votes vote down vote up
private Animation createTranslationOutAnimation() {
    int type = TranslateAnimation.RELATIVE_TO_SELF;
    TranslateAnimation an = new TranslateAnimation(type, 0, type, 0, type,
            0, type, 1);
    an.setDuration(TRANSLATE_DURATION);
    an.setFillAfter(true);
    return an;
}
 
Example 9
Source File: ActionSheet.java    From quickhybrid-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private Animation createTranslationInAnimation() {
    int type = TranslateAnimation.RELATIVE_TO_SELF;
    TranslateAnimation an = new TranslateAnimation(type, 0, type, 0, type, 1, type, 0);
    an.setDuration(TRANSLATE_DURATION);
    return an;
}