Java Code Examples for android.view.animation.AnimationSet#setStartOffset()

The following examples show how to use android.view.animation.AnimationSet#setStartOffset() . 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: CommonViewAnimationActivity.java    From Android-Animation-Set with Apache License 2.0 6 votes vote down vote up
private Animation getAnimationSet(boolean fromXML) {
    if (fromXML) {
        Animation animation = AnimationUtils.loadAnimation(this, R.anim.view_animation);
        return animation;
    } else {
        AnimationSet innerAnimationSet = new AnimationSet(true);
        innerAnimationSet.setInterpolator(new BounceInterpolator());
        innerAnimationSet.setStartOffset(1000);
        innerAnimationSet.addAnimation(getScaleAnimation());
        innerAnimationSet.addAnimation(getTranslateAnimation());

        AnimationSet animationSet = new AnimationSet(true);
        animationSet.setInterpolator(new LinearInterpolator());

        animationSet.addAnimation(getAlphaAnimation());
        animationSet.addAnimation(getRotateAnimation());
        animationSet.addAnimation(innerAnimationSet);

        return animationSet;
    }
}
 
Example 2
Source File: Circle8YMenu.java    From YMenuView with Apache License 2.0 6 votes vote down vote up
@Override
public Animation createOptionShowAnimation(OptionButton optionButton, int index) {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation= new TranslateAnimation(
            getYMenuButton().getX() - optionButton.getX()
            ,0
            ,getYMenuButton().getY() - optionButton.getY()
            ,0);
    translateAnimation.setDuration(getOptionSD_AnimationDuration());
    AlphaAnimation alphaAnimation = new AlphaAnimation(0,1);
    alphaAnimation.setDuration(getOptionSD_AnimationDuration());
    animationSet.addAnimation(alphaAnimation);
    animationSet.addAnimation(translateAnimation);
    //为不同的Option设置延时
    if (index % 2 == 1) {
        animationSet.setStartOffset(getOptionSD_AnimationDuration()/2);
    }
    return animationSet;
}
 
Example 3
Source File: Circle8YMenu.java    From YMenuView with Apache License 2.0 6 votes vote down vote up
@Override
public Animation createOptionDisappearAnimation(OptionButton optionButton, int index) {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation= new TranslateAnimation(
            0
            ,getYMenuButton().getX() - optionButton.getX()
            ,0
            ,getYMenuButton().getY() - optionButton.getY()
    );
    translateAnimation.setDuration(getOptionSD_AnimationDuration());
    AlphaAnimation alphaAnimation = new AlphaAnimation(1,0);
    alphaAnimation.setDuration(getOptionSD_AnimationDuration());
    animationSet.addAnimation(translateAnimation);
    animationSet.addAnimation(alphaAnimation);
    //为不同的Option设置延时
    if (index % 2 == 0) {
        animationSet.setStartOffset(getOptionSD_AnimationDuration()/2);
    }
    return animationSet;
}
 
Example 4
Source File: TreeYMenu.java    From YMenuView with Apache License 2.0 6 votes vote down vote up
@Override
public Animation createOptionDisappearAnimation(OptionButton optionButton, int index) {

    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation= new TranslateAnimation(
            0
            ,getYMenuButton().getX() - optionButton.getX()
            ,0
            ,getYMenuButton().getY() - optionButton.getY()
    );
    translateAnimation.setDuration(getOptionSD_AnimationDuration());
    AlphaAnimation alphaAnimation = new AlphaAnimation(1,0);
    alphaAnimation.setDuration(getOptionSD_AnimationDuration());

    animationSet.addAnimation(translateAnimation);
    animationSet.addAnimation(alphaAnimation);
    //设置动画延时
    animationSet.setStartOffset(60*(getOptionPositionCount() - index));
    return animationSet;
}
 
Example 5
Source File: CommonViewAnimationActivity.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
private Animation getAnimationSet(boolean fromXML) {
    if (fromXML) {
        Animation animation = AnimationUtils.loadAnimation(this, R.anim.view_animation);
        return animation;
    } else {
        AnimationSet innerAnimationSet = new AnimationSet(true);
        innerAnimationSet.setInterpolator(new BounceInterpolator());
        innerAnimationSet.setStartOffset(1000);
        innerAnimationSet.addAnimation(getScaleAnimation());
        innerAnimationSet.addAnimation(getTranslateAnimation());

        AnimationSet animationSet = new AnimationSet(true);
        animationSet.setInterpolator(new LinearInterpolator());

        animationSet.addAnimation(getAlphaAnimation());
        animationSet.addAnimation(getRotateAnimation());
        animationSet.addAnimation(innerAnimationSet);

        return animationSet;
    }
}
 
Example 6
Source File: SquareYMenu.java    From YMenuView with Apache License 2.0 5 votes vote down vote up
@Override
public Animation createOptionShowAnimation(OptionButton optionButton, int index) {
    float fromX,fromY;
    AnimationSet animationSet = new AnimationSet(true);
    if (index < 3){
        fromX = getYMenuButton().getX() - optionButton.getX();
        fromY = getYMenuButton().getY() - optionButton.getY();
    }else if (index < 6){
        fromX = getOptionButtonList().get(0).getX() - optionButton.getX();
        fromY = getOptionButtonList().get(0).getY() - optionButton.getY();
        animationSet.setStartOffset(getOptionSD_AnimationDuration() );
    }else {
        int oldIndex = index % 5;
        fromX = getOptionButtonList().get(oldIndex).getX() - optionButton.getX();
        fromY = getOptionButtonList().get(oldIndex).getY() - optionButton.getY();
        animationSet.setStartOffset(getOptionSD_AnimationDuration() );
    }

    TranslateAnimation translateAnimation= new TranslateAnimation(
            fromX
            ,0
            ,fromY
            ,0);
    translateAnimation.setDuration(getOptionSD_AnimationDuration());
    AlphaAnimation alphaAnimation = new AlphaAnimation(0,1);
    alphaAnimation.setDuration(getOptionSD_AnimationDuration());
    animationSet.addAnimation(alphaAnimation);
    animationSet.addAnimation(translateAnimation);
    animationSet.setInterpolator(new LinearInterpolator());
    return animationSet;

}
 
Example 7
Source File: SquareYMenu.java    From YMenuView with Apache License 2.0 5 votes vote down vote up
@Override
public Animation createOptionDisappearAnimation(OptionButton optionButton, int index) {
    float toX,toY;
    AnimationSet animationSet = new AnimationSet(true);
    if (index < 3){
        toX = getYMenuButton().getX() - optionButton.getX();
        toY = getYMenuButton().getY() - optionButton.getY();
        if (getOptionButtonCount() > 3) {
            animationSet.setStartOffset(getOptionSD_AnimationDuration());
        }
    }else if (index < 6){
        toX = getOptionButtonList().get(0).getX() - optionButton.getX();
        toY = getOptionButtonList().get(0).getY() - optionButton.getY();
    }else {
        int oldIndex = index % 5;
        toX = getOptionButtonList().get(oldIndex).getX() - optionButton.getX();
        toY = getOptionButtonList().get(oldIndex).getY() - optionButton.getY();
    }

    TranslateAnimation translateAnimation= new TranslateAnimation(
            0
            ,toX
            ,0
            ,toY);
    translateAnimation.setDuration(getOptionSD_AnimationDuration());
    AlphaAnimation alphaAnimation = new AlphaAnimation(1,0);
    alphaAnimation.setDuration(getOptionSD_AnimationDuration());
    animationSet.addAnimation(alphaAnimation);
    animationSet.addAnimation(translateAnimation);

    return animationSet;
}
 
Example 8
Source File: TreeYMenu.java    From YMenuView with Apache License 2.0 5 votes vote down vote up
@Override
public Animation createOptionShowAnimation(OptionButton optionButton, int index) {
    float fromX,fromY;
    AnimationSet animationSet = new AnimationSet(true);
    if (index < 3){
        fromX = getYMenuButton().getX() - optionButton.getX();
        fromY = getYMenuButton().getY() - optionButton.getY();
    }else {
        int oldIndex = (index - 3) / 2;
        fromX = getOptionButtonList().get(oldIndex).getX() - optionButton.getX();
        fromY = getOptionButtonList().get(oldIndex).getY() - optionButton.getY();
        //设置冒出动画延时
        animationSet.setStartOffset(getOptionSD_AnimationDuration());
    }

    TranslateAnimation translateAnimation= new TranslateAnimation(
            fromX
            ,0
            ,fromY
            ,0);
    translateAnimation.setDuration(getOptionSD_AnimationDuration());

    AlphaAnimation alphaAnimation = new AlphaAnimation(0,1);
    alphaAnimation.setDuration(getOptionSD_AnimationDuration());

    animationSet.addAnimation(alphaAnimation);
    animationSet.addAnimation(translateAnimation);
    animationSet.setInterpolator(new LinearInterpolator());
    return animationSet;
}
 
Example 9
Source File: AttachmentTypeSelector.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
private void animateButtonIn(View button, int delay) {
  AnimationSet animation = new AnimationSet(true);
  Animation scale = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f,
                                       Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.0f);

  animation.addAnimation(scale);
  animation.setInterpolator(new OvershootInterpolator(1));
  animation.setDuration(ANIMATION_DURATION);
  animation.setStartOffset(delay);
  button.startAnimation(animation);
}
 
Example 10
Source File: LoginActivity.java    From Twire with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    mLoginTextContainer = findViewById(R.id.login_text_container);
    mWebViewProgress = findViewById(R.id.SetupProgress);
    mWebViewContainer = findViewById(R.id.webview_container);
    mContinueFABContainer = findViewById(R.id.login_continue_circle_container);
    mGearIcon = findViewById(R.id.login_icon);
    mSuccessIcon = findViewById(R.id.login_icon_done);
    mContinueIcon = findViewById(R.id.forward_arrow);
    mLoginTextLineOne = findViewById(R.id.login_text_line_one);
    mLoginTextLineTwo = findViewById(R.id.login_text_line_two);
    mSuccessMessage = findViewById(R.id.login_success_message);
    mSkipText = findViewById(R.id.skip_text);
    loginWebView = findViewById(R.id.login_webview);
    mContinueFAB = findViewById(R.id.login_continue_circle);
    mContinueFABShadow = findViewById(R.id.login_continue_circle_shadow);
    mSuccessCircle = findViewById(R.id.login_success_circle);
    mSuccessCircleShadow = findViewById(R.id.login_success_shadow);
    mTransitionViewWhite = findViewById(R.id.transition_view);
    mTransitionViewBlue = findViewById(R.id.transition_view_blue);

    mSuccessMessage.setVisibility(View.INVISIBLE);
    mContinueIcon.setVisibility(View.INVISIBLE);
    mSuccessCircleShadow.setVisibility(View.INVISIBLE);
    mSuccessIcon.setVisibility(View.INVISIBLE);
    mSuccessCircle.setVisibility(View.INVISIBLE);
    mLoginTextLineOne.setVisibility(View.INVISIBLE);
    mLoginTextLineTwo.setVisibility(View.INVISIBLE);
    loginWebView.setVisibility(View.INVISIBLE);
    mGearIcon.setVisibility(View.INVISIBLE);
    mTransitionViewBlue.setVisibility(View.INVISIBLE);
    mTransitionViewWhite.setVisibility(View.INVISIBLE);
    mSkipText.setVisibility(View.INVISIBLE);

    checkSetupType();

    float textPosition = (int) (2.5 * (getScreenHeight() / 5));
    mLoginTextContainer.setY(textPosition);
    mSuccessMessage.setY(textPosition);
    mContinueFABContainer.setOnClickListener(v -> {
        showLoginView();

        if (TwireApplication.isCrawlerUpdate)
            showSkippingAnimation();
    });

    Service.bringToBack(mTransitionViewWhite);
    Service.bringToBack(mTransitionViewBlue);
    mLoginTextLineOne.bringToFront();
    mLoginTextLineTwo.bringToFront();

    initSkipView();
    setupPrelaunchLogin();
    initSnackbar();
    initLoginView();
    showLogoAnimations();
    showTextLineAnimations(mLoginTextLineOne, 1);
    showTextLineAnimations(mLoginTextLineTwo, 2);
    showTextLineAnimations(mSkipText, 2);

    AnimationSet animationSet = getContinueIconAnimations(270);
    int SHOW_CONTINUE_ICON_DELAY = 600;
    animationSet.setStartOffset(SHOW_CONTINUE_ICON_DELAY);
    animationSet.start();
}
 
Example 11
Source File: LoginActivity.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_login);
	trackEvent(R.string.category_read, R.string.action_login);

	mLoginTextContainer 	= findViewById(R.id.login_text_container);
	mWebViewProgress 		= findViewById(R.id.SetupProgress);
	mWebViewContainer 		= findViewById(R.id.webview_container);
	mContinueFABContainer 	= findViewById(R.id.login_continue_circle_container);
	mGearIcon 				= findViewById(R.id.login_icon);
	mSuccessIcon 			= findViewById(R.id.login_icon_done);
	mContinueIcon			= findViewById(R.id.forward_arrow);
	mLoginTextLineOne 		= findViewById(R.id.login_text_line_one);
	mLoginTextLineTwo 		= findViewById(R.id.login_text_line_two);
	mSuccessMessage			= findViewById(R.id.login_success_message);
	mSkipText				= findViewById(R.id.skip_text);
	loginWebView 			= findViewById(R.id.login_webview);
	mContinueFAB 			= findViewById(R.id.login_continue_circle);
	mContinueFABShadow 		= findViewById(R.id.login_continue_circle_shadow);
	mSuccessCircle 			= findViewById(R.id.login_success_circle);
	mSuccessCircleShadow	= findViewById(R.id.login_success_shadow);
	mTransitionViewWhite 	= findViewById(R.id.transition_view);
	mTransitionViewBlue 	= findViewById(R.id.transition_view_blue);

	mSuccessMessage		.setVisibility(View.INVISIBLE);
	mContinueIcon		.setVisibility(View.INVISIBLE);
	mSuccessCircleShadow.setVisibility(View.INVISIBLE);
	mSuccessIcon		.setVisibility(View.INVISIBLE);
	mSuccessCircle		.setVisibility(View.INVISIBLE);
	mLoginTextLineOne	.setVisibility(View.INVISIBLE);
	mLoginTextLineTwo	.setVisibility(View.INVISIBLE);
	loginWebView		.setVisibility(View.INVISIBLE);
	mGearIcon			.setVisibility(View.INVISIBLE);
	mTransitionViewBlue	.setVisibility(View.INVISIBLE);
	mTransitionViewWhite.setVisibility(View.INVISIBLE);
	mSkipText			.setVisibility(View.INVISIBLE);

	checkSetupType();

	float textPosition = (int) (2.5 * (getScreenHeight() / 5));
	mLoginTextContainer	.setY(textPosition);
	mSuccessMessage		.setY(textPosition);
	mContinueFABContainer.setOnClickListener(v -> {
		showLoginView();

		if (PocketPlaysApplication.isCrawlerUpdate)
			showSkippingAnimation();
	});

	Service.bringToBack(mTransitionViewWhite);
	Service.bringToBack(mTransitionViewBlue);
	mLoginTextLineOne		.bringToFront();
	mLoginTextLineTwo		.bringToFront();

	initSkipView();
	setupPrelaunchLogin();
	initSnackbar();
	initLoginView();
	showLogoAnimations();
	showTextLineAnimations(mLoginTextLineOne, 1);
	showTextLineAnimations(mLoginTextLineTwo, 2);
	showTextLineAnimations(mSkipText, 2);

	AnimationSet animationSet = getContinueIconAnimations(270);
	animationSet.setStartOffset(SHOW_CONTINUE_ICON_DELAY);
	animationSet.start();
}