android.animation.AnimatorSet#start ( )源码实例Demo

下面列出了android.animation.AnimatorSet#start ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Sign-Up   文件: SignUp.java
private void ease2(final View view) {
    Easing easing = new Easing(1200);
    AnimatorSet animatorSet = new AnimatorSet();
    float fromY = 600;
    float toY = view.getTop();
    ValueAnimator valueAnimatorY = ValueAnimator.ofFloat(fromY,toY);

    valueAnimatorY.setEvaluator(easing);

    valueAnimatorY.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            view.setTranslationY((float) animation.getAnimatedValue());
        }
    });

    animatorSet.playTogether(valueAnimatorY);
    animatorSet.setDuration(1100);
    animatorSet.start();
}
 
源代码2 项目: gank   文件: VideoImageView.java
private void nextAnimation() {
    // TODO: remove 9 old android.
    AnimatorSet anim = new AnimatorSet();
    if (scale) {
        anim.playTogether(ObjectAnimator.ofFloat(this, "scaleX", 1.5f, 1f),
                ObjectAnimator.ofFloat(this, "scaleY", 1.5f, 1f));
    }
    else {
        anim.playTogether(ObjectAnimator.ofFloat(this, "scaleX", 1, 1.5f),
                ObjectAnimator.ofFloat(this, "scaleY", 1, 1.5f));
    }

    anim.setDuration(10987);
    anim.addListener(this);
    anim.start();
    scale = !scale;
}
 
源代码3 项目: EFRConnect-android   文件: BrowserActivity.java
private void animateToolbarClose(int openPercentHeight, int duration) {
    ValueAnimator animator = ValueAnimator.ofInt(percentHeightToPx(openPercentHeight), 0).setDuration(duration);


    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            Integer value = (Integer) animation.getAnimatedValue();
            frameLayout.getLayoutParams().height = value.intValue();
            frameLayout.requestLayout();
        }
    });

    AnimatorSet set = new AnimatorSet();
    set.play(animator);
    set.setInterpolator(new AccelerateDecelerateInterpolator());
    set.start();
}
 
源代码4 项目: memory-game   文件: PopupManager.java
public static void showPopupWon(GameState gameState) {
	RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container);
	popupContainer.removeAllViews();

	// popup
	PopupWonView popupWonView = new PopupWonView(Shared.context);
	popupWonView.setGameState(gameState);
	int width = Shared.context.getResources().getDimensionPixelSize(R.dimen.popup_won_width);
	int height = Shared.context.getResources().getDimensionPixelSize(R.dimen.popup_won_height);
	RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width, height);
	params.addRule(RelativeLayout.CENTER_IN_PARENT);
	popupContainer.addView(popupWonView, params);

	// animate all together
	ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(popupWonView, "scaleX", 0f, 1f);
	ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(popupWonView, "scaleY", 0f, 1f);
	AnimatorSet animatorSet = new AnimatorSet();
	animatorSet.playTogether(scaleXAnimator, scaleYAnimator);
	animatorSet.setDuration(500);
	animatorSet.setInterpolator(new DecelerateInterpolator(2));
	popupWonView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
	animatorSet.start();
}
 
源代码5 项目: TelePlus-Android   文件: DrawerLayoutContainer.java
public void closeDrawer(boolean fast)
{
    cancelCurrentAnimation();
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(
            ObjectAnimator.ofFloat(this, "drawerPosition", 0)
    );
    animatorSet.setInterpolator(new DecelerateInterpolator());
    if (fast)
    {
        animatorSet.setDuration(Math.max((int) (200.0f / drawerLayout.getMeasuredWidth() * drawerPosition), 50));
    }
    else
    {
        animatorSet.setDuration(300);
    }
    animatorSet.addListener(new AnimatorListenerAdapter()
    {
        @Override
        public void onAnimationEnd(Animator animator)
        {
            onDrawerAnimationEnd(false);
        }
    });
    animatorSet.start();
}
 
源代码6 项目: TelePlus-Android   文件: ChatActivityEnterView.java
private void hideRecordedAudioPanel()
{
    audioToSendPath = null;
    audioToSend = null;
    audioToSendMessageObject = null;
    videoToSendMessageObject = null;
    videoTimelineView.destroy();
    AnimatorSet AnimatorSet = new AnimatorSet();
    AnimatorSet.playTogether(
            ObjectAnimator.ofFloat(recordedAudioPanel, "alpha", 0.0f)
    );
    AnimatorSet.setDuration(200);
    AnimatorSet.addListener(new AnimatorListenerAdapter()
    {
        @Override
        public void onAnimationEnd(Animator animation)
        {
            recordedAudioPanel.setVisibility(GONE);

        }
    });
    AnimatorSet.start();
}
 
源代码7 项目: ZhuanLan   文件: SplashActivity.java
private void animateImage() {
    ObjectAnimator animatorX = ObjectAnimator.ofFloat(mSplashImage, View.SCALE_X, 1f, SCALE_END);
    ObjectAnimator animatorY = ObjectAnimator.ofFloat(mSplashImage, View.SCALE_Y, 1f, SCALE_END);

    AnimatorSet set = new AnimatorSet();
    set.setDuration(ANIMATION_DURATION).play(animatorX).with(animatorY);
    set.start();

    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            MainActivity.start(SplashActivity.this);
            SplashActivity.this.finish();
        }
    });
}
 
源代码8 项目: PlusDemo   文件: MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    view = findViewById(R.id.view);

    ObjectAnimator animator1 = ObjectAnimator.ofFloat(view, "rightFlip", 1);
    animator1.setDuration(500);
    ObjectAnimator animator2 = ObjectAnimator.ofFloat(view, "flipRotation", 270);
    animator2.setDuration(1000);
    animator2.setStartDelay(300);
    ObjectAnimator animator3 = ObjectAnimator.ofFloat(view, "leftFlip", 1);
    animator3.setDuration(500);
    animator3.setStartDelay(300);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playSequentially(animator1, animator2, animator3);
    animatorSet.setStartDelay(600);
    animatorSet.start();
}
 
private void runSwipeAnimation(long time) {
    cancelRunningAnimation();
    mSwipedAway = getTranslationX();

    ObjectAnimator swipe = ObjectAnimator.ofFloat(this, View.TRANSLATION_X,
            getTranslationX() > 0 ? getWidth() : -getWidth());
    ObjectAnimator fadeOut = ObjectAnimator.ofFloat(this, View.ALPHA, 0.f);

    AnimatorSet set = new AnimatorSet();
    set.playTogether(fadeOut, swipe);
    set.addListener(mCloseAnimatorListener);
    set.setDuration(Math.min(time, mDefaultAnimationDurationMs));
    set.start();

    mActiveAnimation = set;
}
 
源代码10 项目: sealtalk-android   文件: AmapActivity.java
private void showLocationView() {
    ObjectAnimator animLocation = ObjectAnimator.ofFloat(tvCurLocation, "TranslationY", 0);
    ObjectAnimator animDestinatiion = ObjectAnimator.ofFloat(tvDestination, "TranslationY", 0);
    AnimatorSet set = new AnimatorSet();
    set.playTogether(animDestinatiion, animLocation);
    set.setDuration(200);
    set.start();
}
 
源代码11 项目: TurboLauncher   文件: AppsCustomizePagedView.java
@Override
public void onClick(View v) {
    // When we have exited all apps or are in transition, disregard clicks
    if (!mLauncher.isAllAppsVisible() ||
            mLauncher.getWorkspace().isSwitchingState()) return;

    if (v instanceof PagedViewIcon) {
        // Animate some feedback to the click
        final AppInfo appInfo = (AppInfo) v.getTag();

        // Lock the drawable state to pressed until we return to Launcher
        if (mPressedIcon != null) {
            mPressedIcon.lockDrawableState();
        }
        mLauncher.startActivitySafely(v, appInfo.intent, appInfo);
        mLauncher.getStats().recordLaunch(appInfo.intent);
    } else if (v instanceof PagedViewWidget) {
        // Let the user know that they have to long press to add a widget
        if (mWidgetInstructionToast != null) {
            mWidgetInstructionToast.cancel();
        }
        mWidgetInstructionToast = Toast.makeText(getContext(),R.string.long_press_widget_to_add,
            Toast.LENGTH_SHORT);
        mWidgetInstructionToast.show();

        // Create a little animation to show that the widget can move
        float offsetY = getResources().getDimensionPixelSize(R.dimen.dragViewOffsetY);
        final ImageView p = (ImageView) v.findViewById(R.id.widget_preview);
        AnimatorSet bounce = LauncherAnimUtils.createAnimatorSet();
        ValueAnimator tyuAnim = LauncherAnimUtils.ofFloat(p, "translationY", offsetY);
        tyuAnim.setDuration(125);
        ValueAnimator tydAnim = LauncherAnimUtils.ofFloat(p, "translationY", 0f);
        tydAnim.setDuration(100);
        bounce.play(tyuAnim).before(tydAnim);
        bounce.setInterpolator(new AccelerateInterpolator());
        bounce.start();
    }
}
 
源代码12 项目: GifAssistant   文件: NavigationWelcomeActivity.java
private void doViewPagerAnimation1(int pagerIndex) {
	if (mPreViewPagerIndex > pagerIndex) {
		mNav2MiddleEveryThingShowImageView.setVisibility(View.INVISIBLE);
	}

	// 时间变换动画
	mNav1TimeShowImageView
			.setImageResource(R.drawable.nav_1_time_show_animation);
	mNav1TimeShowAnimationDrawable = (AnimationDrawable) mNav1TimeShowImageView
			.getDrawable();
	mNav1TimeShowAnimationDrawable.start();

	// 电池图标旋转动画
	mNavBatteryRotateAnimationSet = (AnimatorSet) AnimatorInflater
			.loadAnimator(NavigationWelcomeActivity.this,
					R.anim.nav_1_battery_rotate);
	LinearInterpolator lin = new LinearInterpolator();
	mNavBatteryRotateAnimationSet.setInterpolator(lin);
	mNav1BatteryImageView.setVisibility(View.VISIBLE);
	mNavBatteryRotateAnimationSet.setTarget(mNav1BatteryImageView);
	mNavBatteryRotateAnimationSet.start();

	// 上部图片进入动画
	mNavTopStaticAnimationSet = (AnimatorSet) AnimatorInflater
			.loadAnimator(NavigationWelcomeActivity.this,
					R.anim.nav_1_zoom_top);
	mNavTopStaticAnimationSet.setTarget(mNav1TopStaticImageView);
	mNavTopStaticAnimationSet.start();

}
 
源代码13 项目: TelePlus-Android   文件: PasscodeView.java
private void shakeTextView(final float x, final int num) {
    if (num == 6) {
        return;
    }
    AnimatorSet AnimatorSet = new AnimatorSet();
    AnimatorSet.playTogether(ObjectAnimator.ofFloat(passcodeTextView, "translationX", AndroidUtilities.dp(x)));
    AnimatorSet.setDuration(50);
    AnimatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            shakeTextView(num == 5 ? 0 : -x, num + 1);
        }
    });
    AnimatorSet.start();
}
 
源代码14 项目: Fatigue-Detection   文件: RotateLoading.java
private void startAnimator() {
    ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(this, "scaleX", 0.0f, 1);
    ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(this, "scaleY", 0.0f, 1);
    scaleXAnimator.setDuration(300);
    scaleXAnimator.setInterpolator(new LinearInterpolator());
    scaleYAnimator.setDuration(300);
    scaleYAnimator.setInterpolator(new LinearInterpolator());
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(scaleXAnimator, scaleYAnimator);
    animatorSet.start();
}
 
源代码15 项目: Bailan   文件: ViewUpSearch.java
private void closeSearch() {
    ObjectAnimator anim2 = ObjectAnimator.ofFloat(autoText, "scaleX", 1f, scale);
    ObjectAnimator anim3 = ObjectAnimator.ofFloat(search_circle, "alpha", 0f, 1f);
    search_circle.setVisibility(View.VISIBLE);
    search_icon.setVisibility(View.INVISIBLE);
    ObjectAnimator anim4 = ObjectAnimator.ofFloat(autoText, "alpha", 1f, 0f);
    //setPivotX设置缩放的起始X轴位置为右侧开始Y轴为中间开始
    autoText.setPivotX(autoText.getWidth());
    autoText.setPivotY(autoText.getHeight() / 2);
    AnimatorSet animSet1 = new AnimatorSet();
    animSet1.play(anim2).with(anim3).with(anim4);
    animSet1.setDuration(300);
    animSet1.start();
}
 
源代码16 项目: CameraView   文件: CaptureLayout.java
public void startTypeBtnAnimator() {
    //拍照录制结果后的动画
    if (this.iconLeft != 0)
        iv_custom_left.setVisibility(GONE);
    else
        btn_return.setVisibility(GONE);
    if (this.iconRight != 0)
        iv_custom_right.setVisibility(GONE);
    btn_capture.setVisibility(GONE);
    btn_cancel.setVisibility(VISIBLE);
    btn_confirm.setVisibility(VISIBLE);
    btn_cancel.setClickable(false);
    btn_confirm.setClickable(false);
    ObjectAnimator animator_cancel = ObjectAnimator.ofFloat(btn_cancel, "translationX", layout_width / 4, 0);
    ObjectAnimator animator_confirm = ObjectAnimator.ofFloat(btn_confirm, "translationX", -layout_width / 4, 0);

    AnimatorSet set = new AnimatorSet();
    set.playTogether(animator_cancel, animator_confirm);
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            btn_cancel.setClickable(true);
            btn_confirm.setClickable(true);
        }
    });
    set.setDuration(200);
    set.start();
}
 
源代码17 项目: DanDanPlayForAndroid   文件: AnimHelper.java
/**
 * 执行隐藏动画
 * @param view
 */
public static void doHideAnimator(final View view){
    ObjectAnimator alpha = ObjectAnimator.ofFloat(view, "alpha", 1, 0);
    AnimatorSet set = new AnimatorSet();
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            view.setVisibility(View.GONE);
            super.onAnimationEnd(animation);
        }
    });
    set.setDuration(250);
    set.playTogether(alpha);
    set.start();
}
 
源代码18 项目: Noyze   文件: CircleVolumePanel.java
@Override
public void onStreamVolumeChange(int streamType, int volume, int max) {
    // Cancel any animations already running.
    if (isShowing()) cancelAnimation();

    // Update the icon & progress based on the volume_3 change.
    StreamResources resources = StreamResources.resourceForStreamType(streamType);
    resources.setVolume(volume);
    LOGD(TAG, "onStreamVolumeChange(" + streamType + ", " + volume + ", " + max + ")");
    // Hide the headset when it's not its turn!
    if (mMusicActive || streamType == AudioManager.STREAM_MUSIC) {
        setHeadsetVisibility(View.VISIBLE);
        setHeadset((musicMode == MusicMode.HEADSET) ?
                R.drawable.v5_ic_audio_headset : R.drawable.v5_ic_audio_speaker);
    } else if (streamType == STREAM_BLUETOOTH_SCO) {
        setHeadsetVisibility(View.VISIBLE);
        setHeadset(R.drawable.v5_ic_audio_headset);
    } else {
        setHeadsetVisibility(View.GONE);
    }
    try {
        seekBar.setMax(max);
    } catch (Throwable t) {
        LOGE(TAG, "Error CircleProgressView#setMax(int)", t);
    }
    seekBar.setProgress(volume);
    seekBar.setTag(resources);
    int descRes = resources.getDescRes();
    if (resources.getVolume() <= 0 &&
        (resources == StreamResources.RingerStream ||
         resources == StreamResources.NotificationStream)) {
        if (mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
            descRes = R.string.vibrate_c;
            AnimatorSet set = new AnimatorSet();
            set.play(wiggle(icon)).with(shuffle(root));
            set.start();
            animator = set;
        } else if (mRingerMode == AudioManager.RINGER_MODE_SILENT) {
            descRes = R.string.silent_c;
        }
    }
    streamName.setText(descRes);
    updateIcon(resources);

    // If we've reached the max volume_3, and we weren't there already, pulse!
    if (!hasPulsed && max == volume) {
        animator = pulse();
        animator.start();
    }
    show();
}
 
源代码19 项目: zap-android   文件: ChannelDetailBSDFragment.java
private void switchToFinishScreen(boolean success, String error) {
    mFinishedScreen.setVisibility(View.VISIBLE);

    // Animate Layout changes
    ConstraintSet csRoot = new ConstraintSet();
    csRoot.clone(mRootLayout);
    csRoot.connect(mProgressScreen.getId(), ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP);
    csRoot.setVerticalBias(mProgressScreen.getId(), 0.0f);

    Transition transition = new ChangeBounds();
    transition.setInterpolator(new DecelerateInterpolator(3));
    transition.setDuration(1000);
    TransitionManager.beginDelayedTransition(mRootLayout, transition);
    csRoot.applyTo(mRootLayout);

    // Animate result icon switch
    if (!success) {
        mProgressResultIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_failed_circle_black_60dp));
        mProgressResultIcon.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(getActivity(), R.color.superRed)));
    } else {
        mProgressResultIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_check_circle_black_60dp));
        mProgressResultIcon.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(getActivity(), R.color.superGreen)));
    }

    ObjectAnimator scaleUpX = ObjectAnimator.ofFloat(mProgressResultIcon, "scaleX", 0f, 1f);
    ObjectAnimator scaleUpY = ObjectAnimator.ofFloat(mProgressResultIcon, "scaleY", 0f, 1f);
    scaleUpX.setDuration(500);
    scaleUpY.setDuration(500);

    AnimatorSet scaleUpIcon = new AnimatorSet();
    scaleUpIcon.play(scaleUpX).with(scaleUpY);
    scaleUpIcon.start();

    ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(mProgressBar, "scaleX", 1f, 0f);
    ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(mProgressBar, "scaleY", 1f, 0f);
    ObjectAnimator scaleDownX2 = ObjectAnimator.ofFloat(mProgressThunderIcon, "scaleX", 1f, 0f);
    ObjectAnimator scaleDownY2 = ObjectAnimator.ofFloat(mProgressThunderIcon, "scaleY", 1f, 0f);
    scaleDownX.setDuration(500);
    scaleDownY.setDuration(500);
    scaleDownX2.setDuration(500);
    scaleDownY2.setDuration(500);

    AnimatorSet scaleDownIcon = new AnimatorSet();
    scaleDownIcon.play(scaleDownX).with(scaleDownY).with(scaleDownX2).with(scaleDownY2);
    scaleDownIcon.start();

    if (success) {
        mTvFinishedText.setText(R.string.success);
        mTvFinishedText2.setText(R.string.channel_close_success);
    } else {
        mTvFinishedText.setText(R.string.channel_close_error);
        mTvFinishedText.setTextColor(getResources().getColor(R.color.superRed));
        mTvFinishedText2.setText(error);
    }

    // Animate in
    mFinishedScreen.setAlpha(1.0f);
    AlphaAnimation animateIn = new AlphaAnimation(0f, 1.0f);
    animateIn.setDuration(300);
    animateIn.setStartOffset(300);
    animateIn.setFillAfter(true);

    mFinishedScreen.startAnimation(animateIn);

    // Enable Ok button
    mOkButton.setEnabled(true);
}
 
源代码20 项目: SendBird-Android   文件: TypingIndicator.java
/**
     * Animates all dots in sequential order.
     */
    @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
    public void animate() {
        int startDelay = 0;

        mAnimSet = new AnimatorSet();

        for (int i = 0; i < mImageViewList.size(); i++) {
            ImageView dot = mImageViewList.get(i);
//            ValueAnimator bounce = ObjectAnimator.ofFloat(dot, "y", mAnimMagnitude);
            ValueAnimator fadeIn = ObjectAnimator.ofFloat(dot, "alpha", 1f, 0.5f);
            ValueAnimator scaleX = ObjectAnimator.ofFloat(dot, "scaleX", 1f, 0.7f);
            ValueAnimator scaleY = ObjectAnimator.ofFloat(dot, "scaleY", 1f, 0.7f);

            fadeIn.setDuration(mAnimDuration);
            fadeIn.setInterpolator(new AccelerateDecelerateInterpolator());
            fadeIn.setRepeatMode(ValueAnimator.REVERSE);
            fadeIn.setRepeatCount(ValueAnimator.INFINITE);

            scaleX.setDuration(mAnimDuration);
            scaleX.setInterpolator(new AccelerateDecelerateInterpolator());
            scaleX.setRepeatMode(ValueAnimator.REVERSE);
            scaleX.setRepeatCount(ValueAnimator.INFINITE);

            scaleY.setDuration(mAnimDuration);
            scaleY.setInterpolator(new AccelerateDecelerateInterpolator());
            scaleY.setRepeatMode(ValueAnimator.REVERSE);
            scaleY.setRepeatCount(ValueAnimator.INFINITE);

//            bounce.setDuration(mAnimDuration);
//            bounce.setInterpolator(new AccelerateDecelerateInterpolator());
//            bounce.setRepeatMode(ValueAnimator.REVERSE);
//            bounce.setRepeatCount(ValueAnimator.INFINITE);

//            mAnimSet.play(bounce).after(startDelay);
            mAnimSet.play(fadeIn).after(startDelay);
            mAnimSet.play(scaleX).with(fadeIn);
            mAnimSet.play(scaleY).with(fadeIn);

            mAnimSet.setStartDelay(500);

            startDelay += (mAnimDuration / (mImageViewList.size() - 1));
        }

        mAnimSet.start();
    }